[dmd-concurrency] Shutdown protocol
    Andrei Alexandrescu 
    andrei at erdani.com
       
    Thu Jan 21 12:31:23 PST 2010
    
    
  
Steve Schveighoffer wrote:
> If a thread has exited, it takes probably a few hundred cycles to return, probably not 100ms.
The problem is if it hasn't yet exited (e.g. it's closing files etc.)
> If it has not exited, no amount of parallelism is going to save you from waiting for the thread to exit.
That doesn't dilute my point. Waiting for 100 threads must not be 
waiting for each thread in turn. I can't believe I need to argue this point.
> 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).
Right. join() does come after a broadcast of the intent to terminate.
Andrei
    
    
More information about the dmd-concurrency
mailing list