On 4/4/23 11:34 AM, Salih Dincer wrote:
On Tuesday, 4 April 2023 at 14:20:20 UTC, Steven Schveighoffer wrote:
parallel is a shortcut to `TaskPool.parallel`, which is indeed a
foreach-only construct, it does not return a range.
I think what you want is `TaskPool.map`:
```d
// untested, just looking at the
taskPool.map!(/* your map function here */)
(s.iota(len)).writeln;
```
I tried, thanks but it goes into infinite loop. For example, the first
50 of the sequence should have been printed to the screen immediately
without waiting.
```d
long[50] arr;
RowlandSequence_v2 range;
auto next(long a)
{
range.popFront();
return arr[a] = range.front();
}
void main()
{
range = RowlandSequence_v2(7, 2);
taskPool.map!next(iota(50))/*
s.iota(50)
.map!next
.parallel//*/
.writeln;
}
```
Keep in mind that `arr` and `range` are thread-local, and so will be
different states for different tasks.
Though I don't really know what you are doing there.
-Steve