aboutsummaryrefslogtreecommitdiffstats
path: root/remote.erl
blob: d3cf88a7106d07f248059bbd724b109e4b1f2d10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-module(remote).
-export([start/0, calculate/1]).

rpc(C) ->
    rechner!{self, C},
    receive
        {rechner,  Reply} ->
            Reply
    end.

loop() ->
    receive
        {From, {calculate, String}} ->
            From ! {rechner, {calculate, calculate(String)}},
            loop()
    end.

start() -> 
    register(rechner, spawn(fun () -> loop() end)).

calculate(String) ->
    calc:eval(String).