Skip to content

Instantly share code, notes, and snippets.

@ConnorRigby
Created December 9, 2016 14:39
Show Gist options
  • Save ConnorRigby/64c36d597364ab272c3fb89998088554 to your computer and use it in GitHub Desktop.
Save ConnorRigby/64c36d597364ab272c3fb89998088554 to your computer and use it in GitHub Desktop.
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