[D-runtime] A cooperative suspension API

Sean Kelly sean at invisibleduck.org
Mon May 7 10:07:22 PDT 2012


On May 4, 2012, at 9:45 PM, Alex Rønne Petersen wrote:

> Hi,
> 
> Another feature I want to implement in core.thread is cooperative suspension. In this model, the thread_suspendAll() routine flips a global variable that notifies all threads that they need to suspend. Now, a thread that has marked itself as cooperative is then expected to regularly check this variable and, when it notices that it needs to suspend, does so. This means that the suspension machinery trusts cooperative threads to read this global variable as fast as possible (note that races in reading the variable are acceptable).

Where would the checking be done?  I guess the user would have to call Thread.checkSuspend() or whatever at the appropriate times?


More information about the D-runtime mailing list