summaryrefslogtreecommitdiff
path: root/src/counter.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/counter.erl')
-rw-r--r--src/counter.erl29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/counter.erl b/src/counter.erl
index e566d6c..b46503e 100644
--- a/src/counter.erl
+++ b/src/counter.erl
@@ -1,9 +1,38 @@
-module(counter).
+-behaviour(gen_server).
+-define(SERVER, ?MODULE).
+
+-export([start_link/0]).
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
+ terminate/2, code_change/3]).
-export([start/0, counter/0, next/0, set/1, stop/0]).
-define(MAXCOUNT, 32767).
+start_link() ->
+ gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
+
+init(_Args) ->
+ {ok, 0}.
+
+handle_call(_Request, _From, State) ->
+ {reply, ok, State}.
+
+handle_cast(_Msg, State) ->
+ {noreply, State}.
+
+handle_info(_Info, State) ->
+ {noreply, State}.
+
+terminate(_Reason, _State) ->
+ ok.
+
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
start() ->
register(?MODULE, spawn_link(?MODULE, counter, [])).