diff options
| -rw-r--r-- | src/worker_pool.erl | 16 | ||||
| -rw-r--r-- | src/worker_pool_sup.erl | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/worker_pool.erl b/src/worker_pool.erl index 29cc18dfed..6a2070dd9a 100644 --- a/src/worker_pool.erl +++ b/src/worker_pool.erl @@ -53,7 +53,8 @@ submit/1, submit/2, submit/3, submit_async/1, submit_async/2, ready/2, - idle/2]). + idle/2, + default_pool/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). @@ -64,19 +65,20 @@ -type(mfargs() :: {atom(), atom(), [any()]}). --spec(start_link/1 :: (atom) -> {'ok', pid()} | {'error', any()}). +-spec(start_link/1 :: (atom()) -> {'ok', pid()} | {'error', any()}). -spec(submit/1 :: (fun (() -> A) | mfargs()) -> A). -spec(submit/2 :: (fun (() -> A) | mfargs(), 'reuse' | 'single') -> A). -spec(submit/3 :: (atom(), fun (() -> A) | mfargs(), 'reuse' | 'single') -> A). -spec(submit_async/1 :: (fun (() -> any()) | mfargs()) -> 'ok'). -spec(ready/2 :: (atom(), pid()) -> 'ok'). -spec(idle/2 :: (atom(), pid()) -> 'ok'). +-spec(default_pool/0 :: () -> atom()). -endif. %%---------------------------------------------------------------------------- --define(DEFAULT_SERVER, ?MODULE). +-define(DEFAULT_POOL, ?MODULE). -define(HIBERNATE_AFTER_MIN, 1000). -define(DESIRED_HIBERNATE, 10000). @@ -88,11 +90,11 @@ start_link(Name) -> gen_server2:start_link({local, Name}, ?MODULE, [], [{timeout, infinity}]). submit(Fun) -> - submit(?DEFAULT_SERVER, Fun, reuse). + submit(?DEFAULT_POOL, Fun, reuse). %% ProcessModel =:= single is for working around the mnesia_locker bug. submit(Fun, ProcessModel) -> - submit(?DEFAULT_SERVER, Fun, ProcessModel). + submit(?DEFAULT_POOL, Fun, ProcessModel). submit(Server, Fun, ProcessModel) -> case get(worker_pool_worker) of @@ -101,7 +103,7 @@ submit(Server, Fun, ProcessModel) -> worker_pool_worker:submit(Pid, Fun, ProcessModel) end. -submit_async(Fun) -> submit_async(?DEFAULT_SERVER, Fun). +submit_async(Fun) -> submit_async(?DEFAULT_POOL, Fun). submit_async(Server, Fun) -> gen_server2:cast(Server, {run_async, Fun}). @@ -109,6 +111,8 @@ ready(Server, WPid) -> gen_server2:cast(Server, {ready, WPid}). idle(Server, WPid) -> gen_server2:cast(Server, {idle, WPid}). +default_pool() -> ?DEFAULT_POOL. + %%---------------------------------------------------------------------------- init([]) -> diff --git a/src/worker_pool_sup.erl b/src/worker_pool_sup.erl index dc05a67b0b..c429a4db6c 100644 --- a/src/worker_pool_sup.erl +++ b/src/worker_pool_sup.erl @@ -39,7 +39,7 @@ start_link() -> start_link(erlang:system_info(schedulers)). start_link(WCount) -> - start_link(WCount, worker_pool). + start_link(WCount, worker_pool:default_pool()). start_link(WCount, PoolName) -> SupName = list_to_atom(atom_to_list(PoolName) ++ "_sup"), |
