-
-
Save ericmj/b15bfabd5235746f0a5890df33b9aa19 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"} | |
pid = receive do | |
{:DOWN, ref, :process, pid, reason} -> | |
start(process_type) | |
resp -> | |
IO.puts "Response: #{inspect resp}" | |
pid | |
after 5000 -> | |
IO.puts "Timed out waiting ..." | |
pid | |
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