elib/asset_pool.erl in mojombo-ernie-0.3.2 vs elib/asset_pool.erl in mojombo-ernie-0.3.3

- old
+ new

@@ -1,10 +1,10 @@ -module(asset_pool). -behaviour(gen_server). %% api --export([start_link/1, start/1, lease/0, return/1, reload_assets/0]). +-export([start_link/1, start/1, lease/0, return/1, reload_assets/0, idle_worker_count/0]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). @@ -29,10 +29,13 @@ gen_server:call({global, ?MODULE}, {return, Asset}). reload_assets() -> gen_server:call({global, ?MODULE}, {reload_assets}). +idle_worker_count() -> + gen_server:call({global, ?MODULE}, {idle_worker_count}). + %%==================================================================== %% gen_server callbacks %%==================================================================== %%-------------------------------------------------------------------- @@ -89,9 +92,12 @@ Assets2 = queue:in(NewAsset, State#state.assets), {reply, ok, State#state{assets = Assets2}}; handle_call({reload_assets}, _From, State) -> Token = make_ref(), {reply, ok, State#state{token = Token}}; +handle_call({idle_worker_count}, _From, State) -> + WorkerCount = queue:len(State#state.assets), + {reply, WorkerCount, State}; handle_call(_Request, _From, State) -> {reply, ok, State}. %%-------------------------------------------------------------------- %% Function: handle_cast(Msg, State) -> {noreply, State} | \ No newline at end of file