On Monday, 9 July 2018 at 18:07:49 UTC, Alex wrote:
On Monday, 9 July 2018 at 17:26:30 UTC, vino.B wrote:

Request Help:
void process(alias coRoutine, T...)(Array!string Dirlst, T params)
{
ReturnType!coRoutine rData; ///// This line is not working
      alias scRType = typeof(coRoutine(string.init, T.init));
      auto PFresult = taskPool.workerLocalStorage!scRType();
foreach (string FFs; parallel(Dirlst[],1)) { PFresult.get ~= coRoutine(FFs, params); }
      foreach(i; PFresult.toRange) { rData ~= i[][]; }
}

Error:
test.d(206): Error: template instance `std.traits.ReturnType!(coAgedDirClean)` does not match template declaration ReturnType(func...) if (func.length == 1 && isCallable!func)

Yeah... for ReturnType to work, you need a function, but you have only a template.

The easy solution is to execute the template and to ask the result for its type:

´´´
void main()
{
        process!fun();
}

void process(alias coRoutine, T...)(T params)
{
        auto res = coRoutine(params);
        pragma(msg, typeof(res));
}

auto fun(T...)(T params)
{
        return 42;
}
´´´

If you need it in advance... It is a little bit longer. There was a place, where I used this once...

See
https://run.dlang.io/is/Xy6Xf4

However, I wonder why you need this, especially as your process is void. Why not just using auto for results of the coroutines?

Hi Alex,

The reason the I am storing the output of "PFresult.toRange" to another array "rData" is that the output of the PFresult.toRange is different each time we execute the code.(Data is correct) but the way the it output is different. Is there any way to get the result in a single array - Whole Data.

Single array - Whole Data
["C:\\Temp\\TEAM1\\Test Result-Team1.docx", 2018-Jun-28 17:37:45.9376229, "C:\\Temp\\TEAM2\\Test Result-Team2.docx", 2018-Jun-28 17:37:45.9376229, "C:\\Temp\\SAPNAS3\\TEAM3\\Test Result-Team3.docx", 2018-Jun-28 17:37:45.9376229
]

One array - For Each Data
[ C:\\Temp\\TEAM1\\Test Result-Team1.docx", 2018-Jun-28 17:37:45.9376229] - arr1 [ C:\\Temp\\TEAM2\\Test Result-Team2.docx", 2018-Jun-28 17:37:45.9376229] - arr2 [ C:\\Temp\\TEAM3\\Test Result-Team3.docx", 2018-Jun-28 17:37:45.9376229] - arr3

The code in the program.

 foreach(i; PFresult.toRange) { rData ~= i[][]; }
if (!rData[].empty) { rData[].sort!((a,b) => a[1] < b[1]).each!(e => logF.writefln!"%-83s %.20s"(e[0].replace(`\\?\`, ""), e[1].to!string)); }

From,
Vino.B

Reply via email to