foreach (i; taskPool.parallel(0..2_000_000)
Salih Dincer
salihdb at hotmail.com
Tue Apr 4 15:34:22 UTC 2023
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;
}
```
On Tuesday, 4 April 2023 at 13:18:01 UTC, Ali Çehreli wrote:
> I don't have time to experiment more at this time but I have
> the following chapters, which includes some of those other
> algorithms as well:
>
> http://ddili.org/ders/d/kosut_islemler.html
I read it, thanks...
SDB at 79
More information about the Digitalmars-d-learn
mailing list