3 ms·
I see they are excellent for concurrent programming but is it possible to utilise all cores of processor effectively with coroutines?
by dilawar 6y ago
I see they are excellent for concurrent programming but is it possible to utilise all cores of processor effectively with coroutines?
- jcelerier 6y agoit'd be very trivial with something such as ASIO's io_context as your coroutine event loop: https://dens.website/tutorials/cpp-asio/multithreading https://dens.website/tutorials/cpp-asio/multithreading
- rightbyte 6y agoNo. Think of the coroutines as goto:s with a dynamic label that does some magic to replace locals too. You still need threads.
- b0sk 6y agoNot 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.