|
Boost Users : |
Subject: Re: [Boost-users] [coroutine] Resuming of coroutine from another thread
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2013-09-15 20:15:24
On 9/14/2013 8:54 AM, Quoth Jason Roehm:
> Does the contemporary Boost.Coroutine have the same limitation, or is it
> safe to create a coroutine in one thread and then resume it in another?
While I can't answer this question directly, I can point out that the
examples for Boost.Asio 1.54 show using coroutines as composed operation
handlers, and that naturally Boost.Asio makes no particular guarantees
that only one thread will be used to run handlers (eg. if multiple
threads have called "io_service::run"). So presumably it should be
fine, unless this is an oversight somewhere.
It's likely however that for things to remain safe you will have to
either only have one "run" thread or to use strands or some other
mutual-exclusion method to protect against concurrent execution of the
same coroutine.
(Also note that there have been some fairly dire warnings of problems
with the IOCP scheduler in 1.54 on Windows, so tread carefully.)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net