Skip to content

Instantly share code, notes, and snippets.

@seven1240
Created June 14, 2011 12:38
Show Gist options
  • Save seven1240/1024808 to your computer and use it in GitHub Desktop.
Save seven1240/1024808 to your computer and use it in GitHub Desktop.
fse2
-module(fse2).
-compile(export_all).
start() ->
{foo, 'freeswitch@localhost'} ! register_event_handler,
receive ok -> {event, 'freeswitch@localhost'} ! {event, all}, loop(0) end.
loop(0) ->
io:format("start ~p~n", [erlang:localtime()]),
loop(1);
loop(1000) ->
io:format("end ~p~n", [erlang:localtime()]);
loop(N) ->
receive
ok -> loop(N); % ignore this
{event, [_UUID|_Headers]} ->
{blah, 'freeswitch@localhost'} ! {blah}, % comment this line will be slow
loop(N+1);
{error, _} -> loop(N); %ignore this
M -> io:format("~p~n", [M]), loop(N)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment