|
|
|
|
|
by koudelka
4035 days ago
|
|
The Task module is great for this kind of thing, too. http://elixir-lang.org/docs/v1.0/elixir/Task.html [
add: fn() -> 1+2 end,
hang1: fn() -> :timer.sleep(1000) end,
hang2: fn() -> :timer.sleep(5000) end
]
|> Enum.map(fn {k, t} ->
{k, Task.async(t)}
end)
|> Enum.map(fn {k, t} ->
{k, Task.await(t, :infinity)}
end)
|
|