Task.async_stream
This function has an interesing option :max_concurrency, from the elixir documentation:
Options
:max_concurrency- sets the maximum number of tasks to run at the same time. Defaults toSystem.schedulers_online/0.
Example
stream = Task.async_stream(
collection,
Mod,
:expensive_fun,
[],
max_concurrency: max_concurrency
)
Enum.to_list(stream)