Hi,
Can some one provide me an example of how to wait for all the
threads to be completed in a taskPool and then retrieve the data
of all the threads together instead of getting the data of each
threads(after successfully executed). For example, the below test
program outputs only one string "Welcome" but not the string
"Home".
import std.stdio;
import std.parallelism;
string Data;
auto Textarr = [ "Welcome", "Home" ];
string fn (string text)
{ return text; }
string Submain ()
{
foreach ( i; taskPool.parallel(Textarr[0 .. $], 1))
{
auto Task = task(&fn, i);
Task.executeInNewThread();
auto TaskData = Task.workForce;
Data ~= TaskData;
}
return Data;
}
void main ()
{
Submain;
writeln(Data[0 .. $]);
}
From,
Vino.B