diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-13 12:42:54 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-13 12:42:54 +0000 |
| commit | af0c3ea98cbc8df2b63ba939455715ba8ac828c8 (patch) | |
| tree | 663474dd939cb5bc31ee83f62ac810211afcbfb3 /src | |
| parent | 294ce06ff9a351e5a1ab2e7c3f004de5dba10eef (diff) | |
| download | rabbitmq-server-git-af0c3ea98cbc8df2b63ba939455715ba8ac828c8.tar.gz | |
tweak
- garbage_collect(self()) -> garbage_collect()
- rename some funs / msg tags
- cosmetics
Diffstat (limited to 'src')
| -rw-r--r-- | src/background_gc.erl | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/src/background_gc.erl b/src/background_gc.erl index 0275700f67..7c68a1772c 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. |
