[dmd-concurrency] Shutdown protocol

Sean Kelly sean at invisibleduck.org
Thu Jan 21 12:32:11 PST 2010


On Jan 21, 2010, at 12:26 PM, Steve Schveighoffer wrote:
> 
> If a thread has exited, it takes probably a few hundred cycles to return, probably not 100ms.  If it has not exited, no amount of parallelism is going to save you from waiting for the thread to exit.
> 
> A join sends no messages or anything, it simply waits until the thread has exited and deposited it's return code, then returns the return code.  While you are joining a slow-to-exit thread, all your other threads have exited, so in essence the parallelism occurs because the broadcast of the shutdown gets all the threads ready to be joined.  I don't see any benefit to joinAll (except to avoid having to write a loop).

It might certainly be useful to have a join() routine with a timeout.  But to support that universally we'd have to roll our own, and coordinate using an event variable.


More information about the dmd-concurrency mailing list