Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 13:56
Show Gist options
  • Save rightfold/9206433 to your computer and use it in GitHub Desktop.
Save rightfold/9206433 to your computer and use it in GitHub Desktop.
-module(echo).
-export([go/1, loop/0]).
go(T) ->
Pid2 = spawn(echo, loop, []),
Pid2 ! {self(), hello},
receive
{Pid2, Msg} ->
utils:sleep(T * 1000),
io:format("P! ~w~n",[Msg])
end,
Pid2 ! stop.
loop() ->
receive
{From, Msg} ->
From ! {self(), Msg},
loop();
reload ->
echo:loop();
stop ->
true
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment