aboutsummaryrefslogtreecommitdiff
path: root/src/eco_proc.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/eco_proc.erl')
-rw-r--r--src/eco_proc.erl26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/eco_proc.erl b/src/eco_proc.erl
new file mode 100644
index 0000000..c179a26
--- /dev/null
+++ b/src/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.