Last active
April 26, 2016 20:14
-
-
Save brweber2/92307efe433c4951d3857b7a55a7b079 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 WhatHappensIn_1_3 do | |
def some_func() do | |
receive do | |
{from, message} -> | |
send from, "hello #{inspect message}" | |
some_func() | |
_ -> | |
IO.puts "quittin' time" | |
end | |
end | |
def start() do | |
{pid, ref} = spawn_monitor &some_func/0 | |
send pid, {self(), "Thomas"} | |
receive do | |
{:DOWN, ref, :process, pid, reason} -> | |
pid = start(process_type) # this sets pid in the outer scope... how will this work in Elixir 1.3? Will receive return the value if it doesn't recur? | |
resp -> IO.puts "Response: #{inspect resp}" | |
after 5000 -> | |
IO.puts "Timed out waiting ..." | |
end | |
send pid, {self(), "Sally"} # which pid is used here? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment