diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2012-11-14 11:14:39 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2012-11-14 11:14:39 +0000 |
commit | 563ef0ee5e839b4c1b5567bd8bc2f00e8e1b6b43 (patch) | |
tree | 03c7549aff8dbea42af20e73b4bc9124c98ccada | |
parent | 7bd69bdab5b69e0e2d8ed8b17593e56a61843096 (diff) | |
download | rabbitmq-server-563ef0ee5e839b4c1b5567bd8bc2f00e8e1b6b43.tar.gz |
Work on older Erlang versions
-rw-r--r-- | src/background_gc.erl | 5 | ||||
-rw-r--r-- | src/rabbit_misc.erl | 8 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/background_gc.erl b/src/background_gc.erl index 7c68a177..3dbce330 100644 --- a/src/background_gc.erl +++ b/src/background_gc.erl @@ -19,6 +19,7 @@ -behaviour(gen_server2). -export([start_link/0, run/0]). +-export([gc/0]). %% For run_interval only -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). @@ -34,6 +35,7 @@ -spec(start_link/0 :: () -> {'ok', pid()} | {'error', any()}). -spec(run/0 :: () -> 'ok'). +-spec(gc/0 :: () -> 'ok'). -endif. @@ -67,7 +69,8 @@ terminate(_Reason, State) -> State. interval_gc(State = #state{last_interval = LastInterval}) -> {ok, Interval} = rabbit_misc:interval_operation( - fun gc/0, ?MAX_RATIO, ?IDEAL_INTERVAL, LastInterval), + {?MODULE, gc, []}, + ?MAX_RATIO, ?IDEAL_INTERVAL, LastInterval), erlang:send_after(Interval, self(), run), State#state{last_interval = Interval}. diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 137ccf20..81bb6769 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -237,8 +237,8 @@ -spec(check_expiry/1 :: (integer()) -> rabbit_types:ok_or_error(any())). -spec(base64url/1 :: (binary()) -> string()). -spec(interval_operation/4 :: - (thunk(A), float(), non_neg_integer(), non_neg_integer()) - -> {A, non_neg_integer()}). + ({atom(), atom(), any()}, float(), non_neg_integer(), non_neg_integer()) + -> {any(), non_neg_integer()}). -endif. @@ -1025,8 +1025,8 @@ base64url(In) -> %% more then you want to run it less often. So we time how long it %% takes to run, and then suggest how long you should wait before %% running it again. Times are in millis. -interval_operation(Fun, MaxRatio, IdealInterval, LastInterval) -> - {Micros, Res} = timer:tc(Fun), +interval_operation({M, F, A}, MaxRatio, IdealInterval, LastInterval) -> + {Micros, Res} = timer:tc(M, F, A), {Res, case {Micros > 1000 * (MaxRatio * IdealInterval), Micros > 1000 * (MaxRatio * LastInterval)} of {true, true} -> round(LastInterval * 1.5); |