summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/counter.erl10
-rw-r--r--src/pbx_sup.erl8
2 files changed, 12 insertions, 6 deletions
diff --git a/src/counter.erl b/src/counter.erl
index b46503e..4f4b3f1 100644
--- a/src/counter.erl
+++ b/src/counter.erl
@@ -16,8 +16,14 @@ start_link() ->
init(_Args) ->
{ok, 0}.
-handle_call(_Request, _From, State) ->
- {reply, ok, State}.
+handle_call(next, _From, N) when N >= ?MAXCOUNT ->
+ {reply, 0, 0};
+handle_call(next, _From, N) ->
+ {reply, N + 1, N + 1};
+handle_call(get, _From, N) ->
+ {reply, N, N};
+handle_call({set, N}, _From, _N) ->
+ {reply, N, N}.
handle_cast(_Msg, State) ->
{noreply, State}.
diff --git a/src/pbx_sup.erl b/src/pbx_sup.erl
index 9dd7f60..e9cf6ff 100644
--- a/src/pbx_sup.erl
+++ b/src/pbx_sup.erl
@@ -12,7 +12,7 @@ start_link() ->
init([]) ->
{ok, {
- {one_for_one, 5, 10},
- [ ?CHILD(tda, worker) ]
- } }.
-
+ {one_for_one, 5, 10}, [
+ ?CHILD(tda, worker),
+ ?CHILD(counter, worker)
+ ]}}.