Thread pause and resume

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Apr 6 14:19:46 PDT 2009


Fawzi Mohamed wrote:
> On 2009-04-06 20:49:50 +0200, Steve Teale <steve.teale at britseyeview.com> 
> said:
> 
>> Steve Teale Wrote:
>>
>>> Sean Kelly Wrote:
>>>
>>>> == Quote from Steve Teale (steve.teale at britseyeview.com)'s article
>>>>>
>>>>> 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.
>>>>
>>>> This sounds like a classic producer/consumer case.  I suggest using 
>>>> condition
>>>> variables (core.sync.condition with core.sync.mutex).
>>>
>>> The problem is at the moment, that the D documentation covers the 
>>> language, and Phobos - the latter option exposes Object to some extent.
>>>
>>> Anything that is in core.* is undocumented and you have to 'rtfsc' - 
>>> if you can find it. I can't even find "core.sync" in D files under 
>>> dmd. Can you point me in the right direction please.
>>>
>>> Thanks Steve
>>>
>> As an aside, I realize that Thread.suspend is dodgy, it's been 
>> deprecated in Java and C#. Can the metaprogrammers out there come up 
>> with a way to insist that a particular member function is called only 
>> from the instance that it 'belongs' to. Then presumably it could be 
>> made safe.
> 
> no pause and resume remains a bad idea because [...]

     ^

Insert comma here.


Andrei



More information about the Digitalmars-d mailing list