Re: spawn and wait

2014-07-03 Thread Sean Kelly via Digitalmars-d-learn
On Thursday, 3 July 2014 at 10:25:41 UTC, Bienlein wrote: There is also a Semaphore and Barrier class: http://dlang.org/phobos/core_sync_barrier.html http://dlang.org/phobos/core_sync_semaphore.html This is probably what I'd do, though both this and thread_joinAll will only work if you have on

Re: spawn and wait

2014-07-03 Thread Ali Çehreli via Digitalmars-d-learn
On 07/02/2014 08:29 PM, Puming wrote: > I want to spawn several similar tasks and then wait for all of them to > complete to go on do some other things, like: [...] > My current workaround is using messages: I forgot to mention that if message passing is merely a "workaround" :) in this case

Re: spawn and wait

2014-07-03 Thread Puming via Digitalmars-d-learn
On Thursday, 3 July 2014 at 04:51:07 UTC, Ali Çehreli wrote: On 07/02/2014 08:29 PM, Puming wrote: > I want to spawn several similar tasks and then wait for all of them to > complete to go on do some other things If you don't care about account for each of them individually, core.thread.thread

Re: spawn and wait

2014-07-03 Thread Bienlein via Digitalmars-d-learn
There is also a Semaphore and Barrier class: http://dlang.org/phobos/core_sync_barrier.html http://dlang.org/phobos/core_sync_semaphore.html

Re: spawn and wait

2014-07-02 Thread Ali Çehreli via Digitalmars-d-learn
On 07/02/2014 08:29 PM, Puming wrote: > I want to spawn several similar tasks and then wait for all of them to > complete to go on do some other things If you don't care about account for each of them individually, core.thread.thread_joinAll would work. The following program starts two waves o

spawn and wait

2014-07-02 Thread Puming via Digitalmars-d-learn
Hi, I want to spawn several similar tasks and then wait for all of them to complete to go on do some other things, like: ```d void task(int id) { // do the stuff } void main() { foreach (i; 0..10) { spawn(&task, i); } wait(?); // wait for all task to complete doSomeOtherThings()