def or_(task1, task2) do
parent = self
pid1 = spawn(fn -> send parent, task1.() end)
pid2 = spawn(fn -> send parent, task2.() end)
receive do
false ->
receive do
result2 ->
Process.exit pid1, :kill
Process.exit pid2, :kill
result2
end
true ->
Process.exit pid1, :kill
Process.exit pid2, :kill
true
end
end
https://gist.github.com/roehst/e98a9b0703ceb75d85f7b212b60005ee