How to work around the infamous dual-context when using delegates together with std.parallelism

Ali Çehreli acehreli at yahoo.com
Thu May 27 16:19:08 UTC 2021


On 5/27/21 2:58 AM, Christian Köstlin wrote:

 >      writeln(taskPool.amap!(user => servers.doSomething(user))(users));

Luckily, parallel() is a free-standing function that does not require a 
"this context". Is the following a workaround for you?

   auto result = new string[users.length];
   users.enumerate.parallel.each!(en => result[en.index] = 
servers.doSomething(en.value));
   writeln(result);

Ali




More information about the Digitalmars-d-learn mailing list