diff options
author | Matthew Sackman <matthew@rabbitmq.com> | 2011-05-18 13:30:32 +0100 |
---|---|---|
committer | Matthew Sackman <matthew@rabbitmq.com> | 2011-05-18 13:30:32 +0100 |
commit | 56ffe638d84646c2808b2b7a3bda0bae6a5ed933 (patch) | |
tree | f4ce93cb2dc0a564c0afba0005af9c28e69c05c9 | |
parent | 809585e9e7d1f5640e96622d618b1f7bb5b3d1dd (diff) | |
download | rabbitmq-server-56ffe638d84646c2808b2b7a3bda0bae6a5ed933.tar.gz |
BQ:needs_idle_timeout :: State -> Bool ==> BQ:needs_timeout :: State -> (false | idle | timed); which better reflects the different needs
-rw-r--r-- | include/rabbit_backing_queue_spec.hrl | 2 | ||||
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 7 | ||||
-rw-r--r-- | src/rabbit_backing_queue.erl | 8 | ||||
-rw-r--r-- | src/rabbit_tests.erl | 8 | ||||
-rw-r--r-- | src/rabbit_variable_queue.erl | 30 |
5 files changed, 29 insertions, 26 deletions
diff --git a/include/rabbit_backing_queue_spec.hrl b/include/rabbit_backing_queue_spec.hrl index d9296bf6..f43baf0d 100644 --- a/include/rabbit_backing_queue_spec.hrl +++ b/include/rabbit_backing_queue_spec.hrl @@ -66,7 +66,7 @@ -spec(set_ram_duration_target/2 :: (('undefined' | 'infinity' | number()), state()) -> state()). -spec(ram_duration/1 :: (state()) -> {number(), state()}). --spec(needs_idle_timeout/1 :: (state()) -> boolean()). +-spec(needs_timeout/1 :: (state()) -> 'false' | 'timed' | 'idle'). -spec(idle_timeout/1 :: (state()) -> state()). -spec(handle_pre_hibernate/1 :: (state()) -> state()). -spec(status/1 :: (state()) -> [{atom(), any()}]). diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 110817a9..6a9e6575 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -220,9 +220,10 @@ next_state(State = #q{backing_queue = BQ, backing_queue_state = BQS}) -> ensure_rate_timer( confirm_messages(MsgIds, State#q{ backing_queue_state = BQS1}))), - case BQ:needs_idle_timeout(BQS1) of - true -> {ensure_sync_timer(State1), 0}; - false -> {stop_sync_timer(State1), hibernate} + case BQ:needs_timeout(BQS1) of + false -> {stop_sync_timer(State1), hibernate}; + idle -> {stop_sync_timer(State1), 0 }; + timed -> {ensure_sync_timer(State1), 0 } end. ensure_sync_timer(State = #q{sync_timer_ref = undefined}) -> diff --git a/src/rabbit_backing_queue.erl b/src/rabbit_backing_queue.erl index 0955a080..293b5655 100644 --- a/src/rabbit_backing_queue.erl +++ b/src/rabbit_backing_queue.erl @@ -152,11 +152,11 @@ behaviour_info(callbacks) -> %% Should 'idle_timeout' be called as soon as the queue process %% can manage (either on an empty mailbox, or when a timer %% fires)? - {needs_idle_timeout, 1}, + {needs_timeout, 1}, - %% Called (eventually) after needs_idle_timeout returns - %% 'true'. Note this may be called more than once for each 'true' - %% returned from needs_idle_timeout. + %% Called (eventually) after needs_timeout returns 'idle' or + %% 'timed'. Note this may be called more than once for each + %% 'idle' or 'timed' returned from needs_timeout. {idle_timeout, 1}, %% Called immediately before the queue hibernates. diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 3726420d..5137cce1 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -2269,10 +2269,10 @@ check_variable_queue_status(VQ0, Props) -> VQ1. variable_queue_wait_for_shuffling_end(VQ) -> - case rabbit_variable_queue:needs_idle_timeout(VQ) of - true -> variable_queue_wait_for_shuffling_end( - rabbit_variable_queue:idle_timeout(VQ)); - false -> VQ + case rabbit_variable_queue:needs_timeout(VQ) of + false -> VQ; + _ -> variable_queue_wait_for_shuffling_end( + rabbit_variable_queue:idle_timeout(VQ)) end. test_variable_queue_all_the_bits_not_covered_elsewhere1(VQ0) -> diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl index 7a3c17a2..8e3cbada 100644 --- a/src/rabbit_variable_queue.erl +++ b/src/rabbit_variable_queue.erl @@ -21,7 +21,7 @@ fetch/2, ack/2, tx_publish/5, tx_ack/3, tx_rollback/2, tx_commit/4, requeue/3, len/1, is_empty/1, dropwhile/2, set_ram_duration_target/2, ram_duration/1, - needs_idle_timeout/1, idle_timeout/1, handle_pre_hibernate/1, + needs_timeout/1, idle_timeout/1, handle_pre_hibernate/1, status/1, invoke/3, is_duplicate/3, discard/3, multiple_routing_keys/0]). @@ -830,19 +830,21 @@ ram_duration(State = #vqstate { ram_msg_count_prev = RamMsgCount, ram_ack_count_prev = RamAckCount }}. -needs_idle_timeout(State = #vqstate { on_sync = OnSync }) -> - case {OnSync, needs_index_sync(State)} of - {?BLANK_SYNC, false} -> - {Res, _State} = reduce_memory_use( - fun (_Quota, State1) -> {0, State1} end, - fun (_Quota, State1) -> State1 end, - fun (State1) -> State1 end, - fun (_Quota, State1) -> {0, State1} end, - State), - Res; - _ -> - true - end. + +needs_timeout(State = #vqstate { on_sync = ?BLANK_SYNC }) -> + case needs_index_sync(State) of + true -> timed; + false -> case reduce_memory_use(fun (_Quota, State1) -> {0, State1} end, + fun (_Quota, State1) -> State1 end, + fun (State1) -> State1 end, + fun (_Quota, State1) -> {0, State1} end, + State) of + {true, _State} -> idle; + {false, _State} -> false + end + end; +needs_timeout(_State) -> + timed. idle_timeout(State) -> a(reduce_memory_use(confirm_commit_index(tx_commit_index(State)))). |