Skip to content

Instantly share code, notes, and snippets.

@saivenkat
Created October 8, 2009 17:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saivenkat/205209 to your computer and use it in GitHub Desktop.
Save saivenkat/205209 to your computer and use it in GitHub Desktop.
A simple ping pong based actor example in Erlang
-module(pingpong).
-export([ping/0, pong/0]).
ping()->
receive
{Pid, ping} ->
io:fwrite("Ping received Pong~n",[]),
timer:sleep(3000),
Pid ! {self(), pong},
ping();
stop ->
true
end.
pong() ->
receive
{Pid, pong} ->
io:fwrite("Pong received Ping~n",[]),
timer:sleep(3000),
Pid ! {self(), ping},
pong();
stop ->
true
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment