Open syntheticmagus opened 5 years ago
The base dispatcher
class has a protected tick
that derived classes call. manual_dispatcher
exposes the tick
publicly so the consumer can manually process queued work. For these cases, having a way to pause/resume doesn't make sense (since full control of synchronous ticking is already exposed). For background_dispatcher
, tick
is not exposed and all processing of the work queue is internal. For this case, I could imagine exposing a function from background_dispatcher
that is something like: task<gsl::final_action<void>> pause()
. The idea would be that it is an asynchronous request to pause the work queue (after finishing the current operation/tick if there is one), and returning a gsl::final_action
that is used as a token such that when the caller destroys it, the work queue is resumed.
Add the ability to suspend and resume execution from another thread by setting state (or taking a token or something) on a dispatcher, without having to interact directly with mutexes or locks.