www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Thread pause and resume

reply Steve Teale <steve.teale britseyeview.com> writes:
Sean Kelly Wrote:

 == Quote from Steve Teale (steve.teale 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

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
Apr 06 2009
next sibling parent reply Steve Teale <steve.teale britseyeview.com> writes:
Steve Teale Wrote:

 Sean Kelly Wrote:
 
 == Quote from Steve Teale (steve.teale 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

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

Apr 06 2009
parent reply Fawzi Mohamed <fmohamed mac.com> writes:
On 2009-04-06 20:49:50 +0200, Steve Teale <steve.teale britseyeview.com> said:

 Steve Teale Wrote:
 
 Sean Kelly Wrote:
 
 == Quote from Steve Teale (steve.teale 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

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

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 it can stop the thread in any state, even while it has acquired a lock in any non signal safe kernel function, which means that any other thread could block calling one of these functions until the thread is released, which if you are not very careful might stop the thread that should release it, deadlocking the whole program. Fawzi
Apr 06 2009
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Fawzi Mohamed wrote:
 On 2009-04-06 20:49:50 +0200, Steve Teale <steve.teale britseyeview.com> 
 said:
 
 Steve Teale Wrote:

 Sean Kelly Wrote:

 == Quote from Steve Teale (steve.teale 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

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

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
Apr 06 2009
prev sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
== Quote from Steve Teale (steve.teale britseyeview.com)'s article
 Sean Kelly Wrote:
 == Quote from Steve Teale (steve.teale 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



 pause. The listener thread would then resume it or start one that had never
been started. I'm trying to get it running in


 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).


 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

Darnit... core.sync is supposed to be in src/druntime/import/core/sync, but it isn't there for some reason. I thought this issue had been fixed. Well, in theory it should be there, and I'm working on getting the docs integrated with the Phobos docs. They're already generated by the build...
Apr 06 2009
parent Steve Teale <steve.teale britseyeview.com> writes:
Sean Kelly Wrote:

 == Quote from Steve Teale (steve.teale britseyeview.com)'s article
 Sean Kelly Wrote:
 == Quote from Steve Teale (steve.teale 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



 pause. The listener thread would then resume it or start one that had never
been started. I'm trying to get it running in


 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).


 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

Darnit... core.sync is supposed to be in src/druntime/import/core/sync, but it isn't there for some reason. I thought this issue had been fixed. Well, in theory it should be there, and I'm working on getting the docs integrated with the Phobos docs. They're already generated by the build...

A straight answer to a straight question. Thanks Sean. I'll change my code to let used threads die, and start new ones until I see this stuff.
Apr 06 2009