Maps an
IO-performing function over any
Traversable data
type, performing all the
IO actions concurrently, and
returning the original data structure with the arguments replaced by
the results.
If any of the actions throw an exception, then all other actions are
cancelled and the exception is re-thrown.
For example,
mapConcurrently works with lists:
pages <- mapConcurrently getURL ["url1", "url2", "url3"]
If you just have a list of actions, run them concurrently with
results <- mapConcurrently id [act1, act2, act3]
NOTE:
mapConcurrently will immediately spawn a thread for
each element of the
Traversable, so running this on large
inputs can lead to resource exhaustion (of memory, file descriptors,
or other limited resources). To avoid unbounded resource usage, see
Control.Concurrent.Stream.