aboutsummaryrefslogtreecommitdiffstats
path: root/calc/remote.erl
diff options
context:
space:
mode:
authorMarco Ziener <mziener@lavabit.com>2010-10-13 12:01:52 +0200
committerMarco Ziener <mziener@lavabit.com>2010-10-13 12:01:52 +0200
commitc99c47da34ef134d226c074c30e87319d74e450c (patch)
treecf3c03eb68d45abf95a1c3017e5a3bf5fa31ca42 /calc/remote.erl
parent68f420b2468d4881c66548321c46307f7ce5c5fc (diff)
parent3b4edbdddf8af55f63c22bb3ba80fffa46156dd2 (diff)
downloaderlang-c99c47da34ef134d226c074c30e87319d74e450c.tar.gz
erlang-c99c47da34ef134d226c074c30e87319d74e450c.tar.xz
erlang-c99c47da34ef134d226c074c30e87319d74e450c.zip
Merge branch 'master' of ssh://git.animux.de/erlang
Diffstat (limited to 'calc/remote.erl')
-rw-r--r--calc/remote.erl22
1 files changed, 22 insertions, 0 deletions
diff --git a/calc/remote.erl b/calc/remote.erl
new file mode 100644
index 0000000..793c27c
--- /dev/null
+++ b/calc/remote.erl
@@ -0,0 +1,22 @@
+-module(remote).
+-export([start/0, calculate/1]).
+
+rpc(C) ->
+ rechner ! {self(), C},
+ receive
+ {rechner, Reply} ->
+ Reply
+ end.
+
+loop() ->
+ receive
+ {From, {calculate, String}} ->
+ From ! {rechner, calc:eval(String)},
+ loop()
+ end.
+
+start() ->
+ register(rechner, spawn(fun() -> loop() end)).
+
+calculate(String) ->
+ rpc({calculate, String}).