Function parallelUnorderedMap
Processes a range of items in worker tasks and returns them as an unordered range.
auto parallelUnorderedMap(alias fun, R)
(
R items,
shared(TaskPool) task_pool,
ChannelConfig channel_config = ChannelConfig .init
)
if (isInputRange!R && isWeaklyIsolated!(ElementType!R) && isWeaklyIsolated!(typeof(fun(ElementType!R .init))));
auto parallelUnorderedMap(alias fun, R)
(
R items,
ChannelConfig channel_config = ChannelConfig .init
)
if (isInputRange!R && isWeaklyIsolated!(ElementType!R) && isWeaklyIsolated!(typeof(fun(ElementType!R .init))));
The order of the result stream can deviate from the order of the input items, but the approach is more efficient that an ordered map.#
See also
Example
import std .algorithm : isPermutation, map;
import std .array : array;
import std .range : iota;
auto res = iota(100)
.parallelMap!(i => 2 * i)
.array;
assert(res .isPermutation(iota(100) .map!(i => 2 * i) .array));