Is there any way I can have thread-safe coroutines along with boost::asio?
I want one io_service to be running on multiple threads and to have some of my handlers be coroutines.
Boost.Coroutine would seem to be a solution, but they document that they do not support resuming a coroutine that was started in a separate thread.
As far as I know there are only two possible solutions to this problem:
- Don't use coroutines. Use the much more verbose(even with lambda), but equally functional method of chaining callbacks that store state.
- Force each handler to only run in one thread. I know this is possible by simply having a separate io_service for each thread. As an aside, is there an easy way, similar to io_service::strand, to force a set of handlers to run in the same thread?
Neither are in any way good solutions. In one solution I lose coroutines. In the other I lose most of my multithreading ability.