Search⌘ K
AI Features

taskPool.map() and taskPool.amap()

Explore how to use taskPool.map and taskPool.amap from D's std.parallelism module to perform parallel map operations on ranges. Understand the differences between lazy, semi-eager, and fully eager execution, buffer sizing, and work unit parameters. This lesson helps you improve performance by leveraging parallelism for independent function calls.

We'll cover the following...

taskPool.map()

It helps to explain map() from the std.algorithm module before explaining taskPool.map(). std.algorithm.map is an algorithm commonly found in many functional languages. It calls a function with the elements of a range one-by-one and returns a range that consists of the results of calling that function with each element. It is a lazy algorithm, meaning it calls the function as needed. (There is also std.algorithm.each, which is for generating side effects for each element, as opposed to producing a result from it.)

The fact that std.algorithm.map ...