From a7312ad1cc86cd13be773f83a3b08985dc4e2245 Mon Sep 17 00:00:00 2001 From: Rui Coelho Date: Fri, 24 Feb 2017 17:16:38 +0000 Subject: [PATCH] Add function to get all workers of a pool This is useful for reconfigure (change state) of all the workers --- src/poolboy.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/poolboy.erl b/src/poolboy.erl index db4973b..7bb52d5 100644 --- a/src/poolboy.erl +++ b/src/poolboy.erl @@ -5,7 +5,7 @@ -export([checkout/1, checkout/2, checkout/3, checkin/2, transaction/2, transaction/3, child_spec/2, child_spec/3, start/1, start/2, - start_link/1, start_link/2, stop/1, status/1]). + start_link/1, start_link/2, stop/1, status/1, workers/1]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export_type([pool/0]). @@ -122,6 +122,10 @@ stop(Pool) -> status(Pool) -> gen_server:call(Pool, status). +-spec workers(Pool :: pool()) -> [pid()]. +workers(Pool) -> + [Child|| {_Id, Child, _Type, _Modules} <- gen_server:call(Pool, get_all_workers)]. + init({PoolArgs, WorkerArgs}) -> process_flag(trap_exit, true), Waiting = queue:new(),