summaryrefslogtreecommitdiff
path: root/src/worker_pool_worker.erl
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@lshift.net>2010-04-30 16:03:35 +0100
committerMatthias Radestock <matthias@lshift.net>2010-04-30 16:03:35 +0100
commitbd02893a09a27f00d8b362bdefc58729322d9ea0 (patch)
tree3a774189da84ef0b8744ac6dc22c291e60a007f3 /src/worker_pool_worker.erl
parentbd1f34d8cc55e3a4c09392bddec160116627f315 (diff)
downloadrabbitmq-server-bd02893a09a27f00d8b362bdefc58729322d9ea0.tar.gz
cherry-pick file_handle_cache from bug21673
and its integration with the tcp_acceptor and worker_pool code
Diffstat (limited to 'src/worker_pool_worker.erl')
-rw-r--r--src/worker_pool_worker.erl15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/worker_pool_worker.erl b/src/worker_pool_worker.erl
index d3a48119..d3942a1b 100644
--- a/src/worker_pool_worker.erl
+++ b/src/worker_pool_worker.erl
@@ -35,6 +35,8 @@
-export([start_link/1, submit/2, submit_async/2, run/1]).
+-export([set_maximum_since_use/2]).
+
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
@@ -47,6 +49,8 @@
-spec(submit_async/2 ::
(pid(), fun (() -> any()) | {atom(), atom(), [any()]}) -> 'ok').
+-spec(set_maximum_since_use/2 :: (pid(), non_neg_integer()) -> 'ok').
+
-endif.
%%----------------------------------------------------------------------------
@@ -65,7 +69,14 @@ submit(Pid, Fun) ->
submit_async(Pid, Fun) ->
gen_server2:cast(Pid, {submit_async, Fun}).
+set_maximum_since_use(Pid, Age) ->
+ gen_server2:pcast(Pid, 8, {set_maximum_since_use, Age}).
+
+%%----------------------------------------------------------------------------
+
init([WId]) ->
+ ok = file_handle_cache:register_callback(?MODULE, set_maximum_since_use,
+ [self()]),
ok = worker_pool:idle(WId),
put(worker_pool_worker, true),
{ok, WId, hibernate,
@@ -84,6 +95,10 @@ handle_cast({submit_async, Fun}, WId) ->
ok = worker_pool:idle(WId),
{noreply, WId, hibernate};
+handle_cast({set_maximum_since_use, Age}, WId) ->
+ ok = file_handle_cache:set_maximum_since_use(Age),
+ {noreply, WId, hibernate};
+
handle_cast(Msg, State) ->
{stop, {unexpected_cast, Msg}, State}.