aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/test/server.erl
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2011-09-06 15:27:22 +0200
committerHenrik Nord <[email protected]>2011-09-06 15:29:35 +0200
commit684f1b321c8c4d07edee23737e178976af051913 (patch)
tree320f69cbd3cf279dfaf30a86e6b4099ba57549c0 /lib/observer/test/server.erl
parente7af9a6004cc13f1c49c4b6304adc9b8cd859cba (diff)
parent7e2c8763c225dc16f98cc5746fa141b970a6aaf3 (diff)
downloadotp-684f1b321c8c4d07edee23737e178976af051913.tar.gz
otp-684f1b321c8c4d07edee23737e178976af051913.tar.bz2
otp-684f1b321c8c4d07edee23737e178976af051913.zip
Merge branch 'pd/ttb-cleanup' into major
OTP-9430 OTP-9403 OTP-9431
Diffstat (limited to 'lib/observer/test/server.erl')
-rw-r--r--lib/observer/test/server.erl43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/observer/test/server.erl b/lib/observer/test/server.erl
new file mode 100644
index 0000000000..c1b1fea562
--- /dev/null
+++ b/lib/observer/test/server.erl
@@ -0,0 +1,43 @@
+-module(server).
+-compile(export_all).
+
+start() ->
+ application:start(runtime_tools),
+ Pid = spawn(?MODULE,loop,[[], 0]),
+ register(server,Pid).
+
+stop() ->
+ case lists:member(server, registered()) of
+ true ->
+ server ! stop;
+ false ->
+ ok
+ end.
+
+loop(Data, Num) ->
+ receive
+ {put,From,Ting} -> From ! ok,
+ received(From,Ting),
+ loop([Ting|Data], Num+1);
+ {get,From} -> From ! Data,
+ loop(Data, Num+1);
+ stop -> stopped;
+ clear -> loop([], Num+1);
+ {cnt, From} -> From ! Num,
+ loop(Data, Num)
+ end.
+
+counter() ->
+ server ! {cnt, self()},
+ receive
+ Num ->
+ Num
+ end.
+
+received(From, Thing) ->
+ case Thing of
+ never_send_this_atom ->
+ loop(Thing, 0);
+ _ ->
+ {return, 27, Thing, From}
+ end.