Skip to content

Instantly share code, notes, and snippets.

@binarytemple
Created January 29, 2016 15:12
Show Gist options
  • Save binarytemple/f5f5a34699cdd15e8a6a to your computer and use it in GitHub Desktop.
Save binarytemple/f5f5a34699cdd15e8a6a to your computer and use it in GitHub Desktop.
Playing around with elixir processes
defmodule TProcesses do
def listener() do
receive do
{:hello} -> IO.puts "hello";
Other -> IO.puts "other"
after
12_000 -> IO.puts "timeout"
end
listener()
end
end
p = spawn(TProcesses,:listener, [])
m = Process.monitor(p)
receive do
{:unexpected} -> :unexpected;
after
20_000 -> Process.exit(p,:kill)
end
flush
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment