summaryrefslogtreecommitdiff
path: root/counter.erl
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-10-29 14:00:41 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-10-29 14:00:41 +0100
commitfc86381ccac10fa30aefe76996a716ae1d677f5b (patch)
treec7a0c6c2ab9ab0c254bdb01088c2aad3119ff277 /counter.erl
parentb9697094228db7832e75a8699a2678338f7c7c22 (diff)
Prepare for rebar
Diffstat (limited to 'counter.erl')
-rw-r--r--counter.erl41
1 files changed, 0 insertions, 41 deletions
diff --git a/counter.erl b/counter.erl
deleted file mode 100644
index 98605f6..0000000
--- a/counter.erl
+++ /dev/null
@@ -1,41 +0,0 @@
--module(counter).
-
--export([start/0, counter/0, next/0, set/1, stop/0]).
-
--define(MAXCOUNT, 32767).
-
-start() ->
- register(counterPid, spawn_link(?MODULE, counter, [0])).
-
-counter() ->
- process_flag(trap_exit, true),
- count(0).
-
-count(N) when N > ?MAXCOUNT ->
- count(0);
-
-count(N) ->
- receive
- {next, FromPID} ->
- FromPID ! {next, N},
- count(N+1);
- {set, New} ->
- count(New);
- {'EXIT', Pid, Reason} ->
- io:format("~p: ~p~n", [Pid, Reason]),
- exit(normal);
- {stop} ->
- exit(normal)
- end.
-
-set({present, N}) ->
- counterPid ! {set, N}.
-
-next() ->
- counterPid ! {next, self()},
- receive
- {next, N} -> {present, N}
- end.
-
-stop() ->
- counterPid ! {stop}.