summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-11-13 12:42:54 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2012-11-13 12:42:54 +0000
commit447fbe031b1bd41cc78ea3203fdad11ad137f6b8 (patch)
tree663474dd939cb5bc31ee83f62ac810211afcbfb3
parent57fc2f428c28909a75ad1ef9a0cf3b81fc42fde0 (diff)
downloadrabbitmq-server-bug24915.tar.gz
- garbage_collect(self()) -> garbage_collect() - rename some funs / msg tags - cosmetics
-rw-r--r--src/background_gc.erl40
1 files changed, 15 insertions, 25 deletions
diff --git a/src/background_gc.erl b/src/background_gc.erl
index 0275700f..7c68a177 100644
--- a/src/background_gc.erl
+++ b/src/background_gc.erl
@@ -39,50 +39,40 @@
%%----------------------------------------------------------------------------
-start_link() ->
- gen_server2:start_link({local, ?MODULE}, ?MODULE, [],
- [{timeout, infinity}]).
+start_link() -> gen_server2:start_link({local, ?MODULE}, ?MODULE, [],
+ [{timeout, infinity}]).
-run() ->
- gen_server2:cast(?MODULE, run).
+run() -> gen_server2:cast(?MODULE, run).
%%----------------------------------------------------------------------------
-init([]) ->
- {ok, run_gc(#state{last_interval = ?IDEAL_INTERVAL})}.
+init([]) -> {ok, interval_gc(#state{last_interval = ?IDEAL_INTERVAL})}.
handle_call(Msg, _From, State) ->
{stop, {unexpected_call, Msg}, {unexpected_call, Msg}, State}.
-handle_cast(run, State) ->
- do_gc(),
- {noreply, State};
+handle_cast(run, State) -> gc(), {noreply, State};
-handle_cast(Msg, State) ->
- {stop, {unexpected_cast, Msg}, State}.
+handle_cast(Msg, State) -> {stop, {unexpected_cast, Msg}, State}.
-handle_info(run_gc, State) ->
- {noreply, run_gc(State)};
+handle_info(run, State) -> {noreply, interval_gc(State)};
-handle_info(Msg, State) ->
- {stop, {unexpected_info, Msg}, State}.
+handle_info(Msg, State) -> {stop, {unexpected_info, Msg}, State}.
-code_change(_OldVsn, State, _Extra) ->
- {ok, State}.
+code_change(_OldVsn, State, _Extra) -> {ok, State}.
-terminate(_Reason, State) ->
- State.
+terminate(_Reason, State) -> State.
%%----------------------------------------------------------------------------
-run_gc(State = #state{last_interval = LastInterval}) ->
+interval_gc(State = #state{last_interval = LastInterval}) ->
{ok, Interval} = rabbit_misc:interval_operation(
- fun do_gc/0, ?MAX_RATIO, ?IDEAL_INTERVAL, LastInterval),
- erlang:send_after(Interval, self(), run_gc),
+ fun gc/0, ?MAX_RATIO, ?IDEAL_INTERVAL, LastInterval),
+ erlang:send_after(Interval, self(), run),
State#state{last_interval = Interval}.
-do_gc() ->
+gc() ->
[garbage_collect(P) || P <- processes(),
{status, waiting} == process_info(P, status)],
- garbage_collect(self()), %% Since we will never be waiting...
+ garbage_collect(), %% since we will never be waiting...
ok.