Expand description
Parallel map for loading work that is a pure function of one item (decoding a texture, a
sound or a resource): the results come back in input order, so callers see exactly what a
sequential map gives. Native builds spread the items over the CPU cores with scoped
threads; wasm32 builds run them in order on the calling thread (wasm threads need
cross-origin isolation, see docs/PERFORMANCE.md).
Never use this for work that draws from the game’s Random or depends on the order in
which items are processed.
Functions§
- join
- Run
backgroundon another thread whileforegroundruns on this one (native); on wasm32,foregroundthenbackground, in order.backgroundmust be a pure function of what it reads, so that the order makes no difference. - map
items.iter().map(f).collect(), with the calls tofrun on several threads (native).- map_mut
items.iter_mut().map(f).collect()for disjoint parts of one buffer (for example bands of rows of an image). Each thread takes a run of neighbouring items (native).