Concurrent

Lightweight Enum with concurrency.

Contents

Usage

iex> Concurrent.each([1, 2, 3], fn i -> Process.sleep(500) end)
:ok

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: 2)
[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.3.0"}
  ]
end

Testing

mix deps.get
mix test