aboutsummaryrefslogtreecommitdiff
path: root/eco_proc.erl
diff options
context:
space:
mode:
authorNathan Lasseter <nathan@4574.co.uk>2014-05-30 08:05:19 +0100
committerNathan Lasseter <nathan@4574.co.uk>2014-05-30 08:05:19 +0100
commit59cee25c7f863e76bc82cd58b33f6f3b4e13770c (patch)
treecd238d062a4c58e4c174a322ac02e1bb7e942d69 /eco_proc.erl
Initial Commit
Diffstat (limited to 'eco_proc.erl')
-rw-r--r--eco_proc.erl26
1 files changed, 26 insertions, 0 deletions
diff --git a/eco_proc.erl b/eco_proc.erl
new file mode 100644
index 0000000..c179a26
--- /dev/null
+++ b/eco_proc.erl
@@ -0,0 +1,26 @@
+-module(eco_proc).
+-export([proc/6]).
+
+proc(Watcher, _, _, _, 0, _) ->
+ Watcher ! {died, self()};
+proc(Watcher, Gets, Puts, Pool, Life, MaxLife) ->
+ receive
+ {From, stop} ->
+ From ! {ok, stopped, self()},
+ Watcher ! {stopped, self()},
+ {ok, stopped};
+ {From, tick} ->
+ From ! {self(), tock},
+ Watcher ! {tick, self()},
+ Pool ! {self(), get, Gets},
+ receive
+ {ok, get, Gets} ->
+ Pool ! {self(), put, Puts},
+ receive
+ {ok, put, Puts} ->
+ proc(Watcher, Gets, Puts, Pool, MaxLife, MaxLife)
+ end;
+ {error, get, Gets} ->
+ proc(Watcher, Gets, Puts, Pool, Life - 1, MaxLife)
+ end
+ end.