Hacker News new | ask | show | jobs
by dilawar 1941 days ago
I see they are excellent for concurrent programming but is it possible to utilise all cores of processor effectively with coroutines?
3 comments

Not necessarily. Concurrency is generally not parallelism.

Coroutines help solve IO-bound issues - a long networking API call doesn't block your program. You can continue doing other things. The side-effect of which may use all your cores efficiently but that's not the primary goal.

No. Think of the coroutines as goto:s with a dynamic label that does some magic to replace locals too.

You still need threads.

it'd be very trivial with something such as ASIO's io_context as your coroutine event loop: https://dens.website/tutorials/cpp-asio/multithreading