Created
November 26, 2016 06:37
-
-
Save gaqzi/effa8718a37b0a125a1041ac117f8717 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 PingPonger do | |
def loop do | |
receive do | |
{:pong, sender} -> | |
IO.puts("Pong!") | |
send(sender, {:ping, self}) | |
{:ping, sender} -> | |
IO.puts("Ping?") | |
send(sender, {:pong, self}) | |
:exit -> | |
IO.puts("Quitting") | |
_ -> | |
loop | |
end | |
loop | |
end | |
def ping(ponger) do | |
send(ponger, {:ping, self}) | |
end | |
def pong(pinger) do | |
send(pinger, {:ping, self}) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment