Created
December 9, 2016 14:39
-
-
Save ConnorRigby/64c36d597364ab272c3fb89998088554 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 TimedThing do | |
def thing_that_could_take_a_while(pid) do | |
spawn fn() -> | |
0..10_000 | |
|> Enum.random | |
|> Process.sleep | |
send pid, :hey_im_done | |
end | |
end | |
end | |
defmodule OtherThing do | |
def uh do | |
TimedThing.thing_that_could_take_a_while | |
reveice do | |
:hey_im_done -> IO.puts "its done!" | |
after | |
10_000 -> IO.puts "it took too long!" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment