Skip to content

Instantly share code, notes, and snippets.

@kristjan
Created October 6, 2011 21:55
Show Gist options
  • Save kristjan/1268795 to your computer and use it in GitHub Desktop.
Save kristjan/1268795 to your computer and use it in GitHub Desktop.
An example of loading code over the network. See https://github.com/kristjan/erlang_playground for the full code.
{echo, Server} ! {netload, fun run_faster/0, self()}.
-module(echo).
-export([start/0, run/0]).
start() ->
register(echo, spawn(echo, run, [])).
run() ->
receive
% ...snip...
{netload, Fn, Sender} ->
io:format("Received new code ~p~n", [Fn]),
Sender ! {reply, "Your wish is my command."},
Fn()
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment