Skip to content

Instantly share code, notes, and snippets.

@apboobalan
Created December 22, 2020 06:47
Show Gist options
  • Save apboobalan/a60cbc113f4bc1df41f2b088402ad85b to your computer and use it in GitHub Desktop.
Save apboobalan/a60cbc113f4bc1df41f2b088402ad85b to your computer and use it in GitHub Desktop.
defmodule Taski.Taski do
def async(fun) do
spawning_process = self()
spawn(fn -> spawning_process |> send({self(), fun.()}) end)
end
def await(pid) do
receive do
{^pid, result} -> result
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment