diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-08-21 18:32:09 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-08-21 18:32:09 +0100 |
commit | de1c6973d9766f7cc142ffff24143511d9a8e263 (patch) | |
tree | b7615252e5904aadd8db5ba775fccfaa58a8a21f | |
parent | 760d6145334610e60c76554f92deb9a14319481b (diff) | |
download | rabbitmq-server-de1c6973d9766f7cc142ffff24143511d9a8e263.tar.gz |
Rename boolean to reuse / single.bug25214
-rw-r--r-- | src/rabbit_misc.erl | 2 | ||||
-rw-r--r-- | src/worker_pool.erl | 10 | ||||
-rw-r--r-- | src/worker_pool_worker.erl | 22 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 959f626a..b682ebd3 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -504,7 +504,7 @@ execute_mnesia_transaction(TxFun) -> end; true -> mnesia:sync_transaction(TxFun) end - end, true) of + end, single) of {sync, {atomic, Result}} -> mnesia_sync:sync(), Result; {sync, {aborted, Reason}} -> throw({error, Reason}); {atomic, Result} -> Result; diff --git a/src/worker_pool.erl b/src/worker_pool.erl index 2646258d..608cea91 100644 --- a/src/worker_pool.erl +++ b/src/worker_pool.erl @@ -42,7 +42,7 @@ -spec(start_link/0 :: () -> {'ok', pid()} | {'error', any()}). -spec(submit/1 :: (fun (() -> A) | mfargs()) -> A). --spec(submit/2 :: (fun (() -> A) | mfargs(), boolean()) -> A). +-spec(submit/2 :: (fun (() -> A) | mfargs(), 'reuse' | 'single') -> A). -spec(submit_async/1 :: (fun (() -> any()) | mfargs()) -> 'ok'). -spec(ready/1 :: (pid()) -> 'ok'). -spec(idle/1 :: (pid()) -> 'ok'). @@ -63,14 +63,14 @@ start_link() -> gen_server2:start_link({local, ?SERVER}, ?MODULE, [], [{timeout, infinity}]). submit(Fun) -> - submit(Fun, false). + submit(Fun, reuse). -%% OneOffProcess =:= true is for working around the mnesia_locker bug. -submit(Fun, OneOffProcess) -> +%% ProcessModel =:= single is for working around the mnesia_locker bug. +submit(Fun, ProcessModel) -> case get(worker_pool_worker) of true -> worker_pool_worker:run(Fun); _ -> Pid = gen_server2:call(?SERVER, {next_free, self()}, infinity), - worker_pool_worker:submit(Pid, Fun, OneOffProcess) + worker_pool_worker:submit(Pid, Fun, ProcessModel) end. submit_async(Fun) -> gen_server2:cast(?SERVER, {run_async, Fun}). diff --git a/src/worker_pool_worker.erl b/src/worker_pool_worker.erl index 14b2df79..819a6ae8 100644 --- a/src/worker_pool_worker.erl +++ b/src/worker_pool_worker.erl @@ -33,7 +33,7 @@ -spec(start_link/0 :: () -> {'ok', pid()} | {'error', any()}). -spec(next_job_from/2 :: (pid(), pid()) -> 'ok'). --spec(submit/3 :: (pid(), fun (() -> A) | mfargs(), boolean()) -> A). +-spec(submit/3 :: (pid(), fun (() -> A) | mfargs(), 'reuse' | 'single') -> A). -spec(submit_async/2 :: (pid(), fun (() -> any()) | mfargs()) -> 'ok'). -spec(run/1 :: (fun (() -> A)) -> A; (mfargs()) -> any()). -spec(set_maximum_since_use/2 :: (pid(), non_neg_integer()) -> 'ok'). @@ -53,8 +53,8 @@ start_link() -> next_job_from(Pid, CPid) -> gen_server2:cast(Pid, {next_job_from, CPid}). -submit(Pid, Fun, OneOffProcess) -> - gen_server2:call(Pid, {submit, Fun, self(), OneOffProcess}, infinity). +submit(Pid, Fun, ProcessModel) -> + gen_server2:call(Pid, {submit, Fun, self(), ProcessModel}, infinity). submit_async(Pid, Fun) -> gen_server2:cast(Pid, {submit_async, Fun}). @@ -65,9 +65,9 @@ set_maximum_since_use(Pid, Age) -> run({M, F, A}) -> apply(M, F, A); run(Fun) -> Fun(). -run(Fun, false) -> +run(Fun, reuse) -> run(Fun); -run(Fun, true) -> +run(Fun, single) -> Self = self(), Ref = make_ref(), spawn_link(fun () -> @@ -93,12 +93,12 @@ prioritise_cast({set_maximum_since_use, _Age}, _Len, _State) -> 8; prioritise_cast({next_job_from, _CPid}, _Len, _State) -> 7; prioritise_cast(_Msg, _Len, _State) -> 0. -handle_call({submit, Fun, CPid, OneOffProcess}, From, undefined) -> - {noreply, {job, CPid, From, Fun, OneOffProcess}, hibernate}; +handle_call({submit, Fun, CPid, ProcessModel}, From, undefined) -> + {noreply, {job, CPid, From, Fun, ProcessModel}, hibernate}; -handle_call({submit, Fun, CPid, OneOffProcess}, From, {from, CPid, MRef}) -> +handle_call({submit, Fun, CPid, ProcessModel}, From, {from, CPid, MRef}) -> erlang:demonitor(MRef), - gen_server2:reply(From, run(Fun, OneOffProcess)), + gen_server2:reply(From, run(Fun, ProcessModel)), ok = worker_pool:idle(self()), {noreply, undefined, hibernate}; @@ -109,8 +109,8 @@ handle_cast({next_job_from, CPid}, undefined) -> MRef = erlang:monitor(process, CPid), {noreply, {from, CPid, MRef}, hibernate}; -handle_cast({next_job_from, CPid}, {job, CPid, From, Fun, OneOffProcess}) -> - gen_server2:reply(From, run(Fun, OneOffProcess)), +handle_cast({next_job_from, CPid}, {job, CPid, From, Fun, ProcessModel}) -> + gen_server2:reply(From, run(Fun, ProcessModel)), ok = worker_pool:idle(self()), {noreply, undefined, hibernate}; |