Show HN: Parex – Simple Elixir module for parallel execution
github.com
github.com
[
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)Whether the code is executed on many cores or not is completely orthogonal to this library. Indeed it is a property of the Erlang VM: you can configure it to run on only one system process, or many.
That said, if you are looking for computing performances, Erlang/Elixir is probably not the language of choice: it is optimized for latency and fault tolerance, not to maximize raw cpu usage.
This is very cool though!