Concurrent
Lightweight Enum with concurrency.
Contents
Usage
iex> Concurrent.map([1, 2, 3], fn i ->
Process.sleep(1_000)
i * i
end)
[1, 4, 9]To set a timeout for each element function execution:
iex> Concurrent.map([1, 2, 3], &(&1 * &1), timeout: 500)
[1, 4, 9]To limit the number of concurrent executions:
iex> Concurrent.map([1, 2, 3], &(&1 * &1), batch_size: 10)
[1, 4, 9]Installation
The package can be installed by adding concurrent to your list of dependencies in mix.exs:
def deps do
[
{:concurrent, "~> 0.2.0"}
]
endTesting
mix deps.get
mix test