spawn X different workers & wait for results from all of them
Robert M. Münch via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Sep 5 09:46:19 PDT 2015
On 2015-09-05 15:44:02 +0000, thedeemon said:
> I think the Task and taskPool from std.parallelism are a good fit.
> Something like:
>
> auto task1 = task!fun1(params1);
> auto task2 = task!fun2(params2);
> auto task3 = task!fun3(params3);
> auto task4 = task!fun4(params4);
>
> taskPool.put(task1);
> taskPool.put(task2);
> taskPool.put(task3);
> taskPool.put(task4);
>
> auto res1 = task1.workForce();
> auto res2 = task2.workForce();
> auto res3 = task3.workForce();
> auto res4 = task4.workForce();
>
> //here we have all the results, they were calculated in parallel
Thanks, that looks pretty good. Going to x-check how this could be used.
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
More information about the Digitalmars-d-learn
mailing list