Created
February 9, 2016 20:03
-
-
Save domnikl/3c4116b27d12363e7c4f to your computer and use it in GitHub Desktop.
examples for links in Elixir http://eddwardo.github.io/elixir/links/2015/11/04/links-in-elixir/
This file contains 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
Process.flag(:trap_exit, true) | |
current = self() | |
spawn(fn -> send(current, {self(), 1 + 1}); exit(:no_normal_exit) end) | |
defmodule Foobar do | |
def foo(current) do | |
receive do | |
{current, n} -> IO.puts "Result: #{n}"; foo(current) | |
{:EXIT, pid, reason} -> IO.puts "EXIT with #{reason}" | |
after 10 -> IO.puts :stderr, "Timeout" | |
end | |
end | |
end | |
Foobar.foo(current) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment