On Thu, 03 Sep 2015 18:50:21 +0200, Robert M. Münch wrote: > Hi, I'm not sure how to best implement the following: > > 1. I have 4 different tasks to do. > 2. All can run in parallel 3. Every task will return some result that I > need > > Now how to best do it? When using receive() it fires on the first hit > and the function continues. It's like a receive(OR), one hit and it's > done. So, I would need something like a receive(ALL) that continues only > of all results (messages) have been received. > > Is something like this available or do I have to build it myself?
How would receive know? If you're using std.concurrency, the receiving function needs to encode doneness, e.g. const numJobs = 4; foreach (_; 0 .. numJobs) receive(...); Or you could use std.parallelism: foreach (pieceOfWork; parallel(listOfWork)) doIt(pieceOfWork);