Created
December 22, 2020 06:47
-
-
Save apboobalan/a60cbc113f4bc1df41f2b088402ad85b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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