summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/worker_pool.erl8
-rw-r--r--src/worker_pool_worker.erl2
2 files changed, 6 insertions, 4 deletions
diff --git a/src/worker_pool.erl b/src/worker_pool.erl
index b883d4f0cb..1ee958afb6 100644
--- a/src/worker_pool.erl
+++ b/src/worker_pool.erl
@@ -93,9 +93,11 @@ handle_call(next_free, From, State = #state { available = Avail,
pending = Pending }) ->
case queue:out(Avail) of
{empty, _Avail} ->
- {noreply, State #state { pending = queue:in(From, Pending) }};
+ {noreply, State #state { pending = queue:in(From, Pending) },
+ hibernate};
{{value, WId}, Avail1} ->
- {reply, get_worker_pid(WId), State #state { available = Avail1 }}
+ {reply, get_worker_pid(WId), State #state { available = Avail1 },
+ hibernate}
end;
handle_call(Msg, _From, State) ->
@@ -109,7 +111,7 @@ handle_cast({idle, WId}, State = #state { available = Avail,
{{value, From}, Pending1} ->
gen_server2:reply(From, get_worker_pid(WId)),
State #state { pending = Pending1 }
- end};
+ end, hibernate};
handle_cast(Msg, State) ->
{stop, {unexpected_cast, Msg}, State}.
diff --git a/src/worker_pool_worker.erl b/src/worker_pool_worker.erl
index fc3ce3714f..3bfcc2d9ff 100644
--- a/src/worker_pool_worker.erl
+++ b/src/worker_pool_worker.erl
@@ -69,7 +69,7 @@ init([WId]) ->
handle_call({submit, Fun}, From, WId) ->
gen_server2:reply(From, run(Fun)),
ok = worker_pool:idle(WId),
- {noreply, WId};
+ {noreply, WId, hibernate};
handle_call(Msg, _From, State) ->
{stop, {unexpected_call, Msg}, State}.