Skip to content

Instantly share code, notes, and snippets.

@brweber2
Last active April 26, 2016 20:14
Show Gist options
  • Save brweber2/92307efe433c4951d3857b7a55a7b079 to your computer and use it in GitHub Desktop.
Save brweber2/92307efe433c4951d3857b7a55a7b079 to your computer and use it in GitHub Desktop.
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