Thread pause and resume
Steve Teale
steve.teale at britseyeview.com
Mon Apr 6 07:14:41 PDT 2009
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.
In some code I wrote at that time, I had a worker thread pool. When a thread had done its job it would mark itself as available then pause. The listener thread would then resume it or start one that had never been started. I'm trying to get it running in 2.26. There are functions of the same name there but they are nested inside SuspendAll and ResumeAll, and so not accessible.
More information about the Digitalmars-d
mailing list