[dmd-concurrency] Shutdown protocol
Andrei Alexandrescu
andrei at erdani.com
Thu Jan 21 12:17:51 PST 2010
Steve Schveighoffer wrote:
>> From: Andrei Alexandrescu <andrei at erdani.com>
>> The idea is to join on all threads in parallel. Otherwise, if you
>> have N threads, the Nth will become aware you plan to shutdown only
>> after all others have already finished.
>
> Hm... in all other threading libraries I used, calling join did not
> change the state of the thread at all, it just waited for the thread
> to return. So in those libraries, "joining threads in parallel" had
> no effect.
What I mean is the following. Before joining threads and terminate app,
you have a means to tell them it's about time to finish. So the sequence
looks like this:
broadcastShutdown();
joinAll();
Now say you have 24 threads with a latency of 100ms each. If you join
them serially, it takes 2.4 seconds. If you join them simultaneously, it
ideally takes 100ms.
> I thought triggering a shutdown would be done separately from join
> (see the call to "shutdown()" in my code sample).
Correct.
Andrei
More information about the dmd-concurrency
mailing list