[dmd-concurrency] Shutdown protocol
Steve Schveighoffer
schveiguy at yahoo.com
Thu Jan 21 11:59:29 PST 2010
----- Original Message ----
> From: Andrei Alexandrescu <andrei at erdani.com>
>
> Steve Schveighoffer wrote:
> > ----- Original Message ----
> >
> >> From: Andrei Alexandrescu
> >> Steve Schveighoffer wrote:
> >>> foreach(tid; tids) {tid.join();}
> >> Oh btw that shouldn't be coded like that, it's slow. Must be something like:
> >>
> >> joinAll(tids);
> >>
> >> so joining is initiated in parallel.
> >>
> >
> > What does joinAll do? I admit I am not too familiar with your proposed API.
>
> 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.
I thought triggering a shutdown would be done separately from join (see the call to "shutdown()" in my code sample).
In that case, you may wish to rename what you call "join" and "joinAll", since a common usage of join in other threading libraries (including pthreads) is to wait until a thread has exited, not to tell it that it should shut down. It will cause confusion if it's named the same in D but does something different.
-Steve
More information about the dmd-concurrency
mailing list