vibe.d beta banner
get vibe.d
0.9.4

Asynchronous I/O that doesn’t get in your way, written in D

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

parallelMap

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));
Authors

Sönke Ludwig

Copyright

© 2021 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.