summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-09-14 14:37:32 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-09-14 14:37:32 +0100
commitdf90e7d72fd783aa2d549239d924d097f8232502 (patch)
tree6c8d60e5c82baee697a62f78ee6b724f7797866b
parentc7adba2699012406f4a37fcb933fb7168f1c7ede (diff)
downloadrabbitmq-server-df90e7d72fd783aa2d549239d924d097f8232502.tar.gz
make the serialiser more generic by not registering it on start_link
-rw-r--r--src/file2.erl3
-rw-r--r--src/rabbit.erl6
-rw-r--r--src/serialiser.erl23
3 files changed, 13 insertions, 19 deletions
diff --git a/src/file2.erl b/src/file2.erl
index d9ee1da8..4d945fc4 100644
--- a/src/file2.erl
+++ b/src/file2.erl
@@ -900,7 +900,8 @@ mode_list(_) ->
%% Functions for communicating with the file server
call(Command, Args) when is_list(Args) ->
- io_runner:submit(
+ serialiser:submit(
+ serialiser,
fun () ->
gen_server:call(?FILE_SERVER, list_to_tuple([Command | Args]),
infinity)
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 22905320..3e311747 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -58,12 +58,6 @@
{requires, pre_boot},
{enables, external_infrastructure}]}).
--rabbit_boot_step({io_runner,
- [{description, "IO runner"},
- {mfa, {rabbit_sup, start_child, [io_runner]}},
- {requires, pre_boot},
- {enables, external_infrastructure}]}).
-
-rabbit_boot_step({external_infrastructure,
[{description, "external infrastructure ready"}]}).
diff --git a/src/serialiser.erl b/src/serialiser.erl
index 1fe0ec8f..958f0d50 100644
--- a/src/serialiser.erl
+++ b/src/serialiser.erl
@@ -18,7 +18,7 @@
-behaviour(gen_server2).
--export([start_link/0, submit/1]).
+-export([start_link/0, submit/2]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
@@ -28,28 +28,29 @@
-ifdef(use_specs).
-spec(start_link/0 :: () -> {'ok', pid()} | {'error', any()}).
--spec(submit/1 :: (fun (() -> A) | {atom(), atom(), [any()]}) -> A).
+-spec(submit/2 ::
+ (pid() | atom(), fun (() -> A) | {atom(), atom(), [any()]}) -> A).
-endif.
%%----------------------------------------------------------------------------
--define(SERVER, ?MODULE).
-define(HIBERNATE_AFTER_MIN, 1000).
-define(DESIRED_HIBERNATE, 10000).
%%----------------------------------------------------------------------------
start_link() ->
- gen_server2:start_link({local, ?SERVER}, ?MODULE, [],
- [{timeout, infinity}]).
+ gen_server2:start_link(?MODULE, [], [{timeout, infinity}]).
-submit(Fun) ->
+submit(Pid, Fun) when is_pid(Pid) ->
+ gen_server2:call(Pid, {run, Fun}, infinity);
+submit(Server, Fun) ->
%% If the io_runner is not running, just run the Fun in the
%% current process.
- case whereis(?SERVER) of
+ case whereis(Server) of
undefined -> run(Fun);
- _ -> gen_server2:call(?SERVER, {run, Fun}, infinity)
+ _ -> gen_server2:call(Server, {run, Fun}, infinity)
end.
%%----------------------------------------------------------------------------
@@ -77,7 +78,5 @@ terminate(_Reason, State) ->
%%----------------------------------------------------------------------------
-run({M, F, A}) ->
- apply(M, F, A);
-run(Fun) ->
- Fun().
+run({M, F, A}) -> apply(M, F, A);
+run(Fun) -> Fun().