diff options
author | Hans Bolinder <[email protected]> | 2017-09-25 15:38:33 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-12-20 13:55:08 +0100 |
commit | b8f16f0ab8099733a9fb1651c74af9cd1f8837ff (patch) | |
tree | ac6a0d448f107968b21e3fd96a68d3ad02ce4b48 /lib/stdlib/test/stdlib_bench_SUITE_data/simple_server_mon.erl | |
parent | 18a08499db5223dfc3c96b64220a4b3e6a79c799 (diff) | |
download | otp-b8f16f0ab8099733a9fb1651c74af9cd1f8837ff.tar.gz otp-b8f16f0ab8099733a9fb1651c74af9cd1f8837ff.tar.bz2 otp-b8f16f0ab8099733a9fb1651c74af9cd1f8837ff.zip |
stdlib: Introduce gen_server benchmark
Diffstat (limited to 'lib/stdlib/test/stdlib_bench_SUITE_data/simple_server_mon.erl')
-rw-r--r-- | lib/stdlib/test/stdlib_bench_SUITE_data/simple_server_mon.erl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/stdlib/test/stdlib_bench_SUITE_data/simple_server_mon.erl b/lib/stdlib/test/stdlib_bench_SUITE_data/simple_server_mon.erl new file mode 100644 index 0000000000..9b5ace5586 --- /dev/null +++ b/lib/stdlib/test/stdlib_bench_SUITE_data/simple_server_mon.erl @@ -0,0 +1,33 @@ +-module(simple_server_mon). + +%% Local process. No timer. Monitor. + +-export([start/1, reply/2, stop/1]). + +start(State) -> + spawn(fun() -> loop(State) end). + +stop(P) -> + P ! {stop, self()}, + receive + ok -> + ok + end. + +loop(S) -> + receive + {reply, P, Mref, M} -> + P ! {ok, Mref, M}, + loop(S); + {stop, P} -> + P ! ok + end. + +reply(P, M) -> + Mref = erlang:monitor(process, P), + P ! {reply, self(), Mref, M}, + receive + {ok, Mref, M} -> + erlang:demonitor(Mref, [flush]), + ok + end. |