aboutsummaryrefslogtreecommitdiffstats
path: root/calc/remote.erl
diff options
context:
space:
mode:
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}).