diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit.erl | 12 | ||||
| -rw-r--r-- | src/worker_pool_worker.erl | 15 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 387b3256bb..de2fec574c 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -53,6 +53,12 @@ [{mfa, {rabbit_mnesia, init, []}}, {enables, external_infrastructure}]}). +-rabbit_boot_step({file_handle_cache, + [{description, "file handle cache server"}, + {mfa, {rabbit_sup, start_restartable_child, + [file_handle_cache]}}, + {enables, worker_pool}]}). + -rabbit_boot_step({worker_pool, [{description, "worker pool"}, {mfa, {rabbit_sup, start_child, [worker_pool_sup]}}, @@ -81,12 +87,6 @@ {enables, kernel_ready}, {requires, external_infrastructure}]}). --rabbit_boot_step({file_handle_cache, - [{description, "file handle cache server"}, - {mfa, {rabbit_sup, start_restartable_child, - [file_handle_cache]}}, - {enables, kernel_ready}]}). - -rabbit_boot_step({kernel_ready, [{description, "kernel ready"}, {requires, external_infrastructure}]}). diff --git a/src/worker_pool_worker.erl b/src/worker_pool_worker.erl index 4defc5bafe..5a6ccb1609 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]). @@ -64,7 +66,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, @@ -81,7 +90,11 @@ handle_call(Msg, _From, State) -> handle_cast({submit_async, Fun}, WId) -> run(Fun), ok = worker_pool:idle(WId), - {noreply, 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}. |
