Thread pause and resume

Robert Jacques sandford at jhu.edu
Mon Apr 6 18:22:32 PDT 2009


On Mon, 06 Apr 2009 10:14:41 -0400, Steve Teale  
<steve.teale at britseyeview.com> wrote:

> Robert Jacques Wrote:
>
>> On Mon, 06 Apr 2009 05:57:24 -0400, Steve Teale
>> <steve.teale at britseyeview.com> wrote:
>>
>> > Earlier versions of D2.x used std.thread which had pause() and  
>> resume().
>> > The later versions use core.thread where these appear to be missing.
>> >
>> > Any portable workaround suggestions?
>> >
>>
>> Also, these functions (if you dig into their implementation) are
>> documented as being for debuggers and/or GCs only. Specifically, they  
>> can
>> not be used for synchronization, etc.
>
> In 2.06 they were just:
>
>     /**
>      * Suspend execution of this thread.
>      */
>     void pause()
>     {
> 	if (state != TS.RUNNING || SuspendThread(hdl) == 0xFFFFFFFF)
> 	    error("cannot pause");
>     }
>
>     /**
>      * Resume execution of this thread.
>      */
>     void resume()
>     {
> 	if (state != TS.RUNNING || ResumeThread(hdl) == 0xFFFFFFFF)
> 	    error("cannot resume");
>     }
>
> No prohibitions or warnings.

Okay, now follow SuspendThread and ResumeThread and you'll eventually run  
into a (on windows) a function call which is documented on MSDN with a  
bunch of warnings. Admittedly, I traced this a while ago, so pause and  
resume might have been re-purposed away from GC use, but this used to be  
the case.



More information about the Digitalmars-d mailing list