summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-06-26 16:43:14 +0100
committerSimon MacMullen <simon@rabbitmq.com>2013-06-26 16:43:14 +0100
commit2603ee565e09d196b4b24ce0bd88c84d721249df (patch)
tree9ff2b6462db662ddcc4a2103c3e14c382492d2cc /src
parentf33d2ab02311bfe23b7c450a8ca604b5619109a2 (diff)
downloadrabbitmq-server-git-2603ee565e09d196b4b24ce0bd88c84d721249df.tar.gz
TODO-- yes it could be faster.
Diffstat (limited to 'src')
-rw-r--r--src/priority_queue.erl6
-rw-r--r--src/rabbit_amqqueue_process.erl5
2 files changed, 6 insertions, 5 deletions
diff --git a/src/priority_queue.erl b/src/priority_queue.erl
index 3c46c4cee2..572bca95ee 100644
--- a/src/priority_queue.erl
+++ b/src/priority_queue.erl
@@ -41,7 +41,7 @@
-module(priority_queue).
-export([new/0, is_queue/1, is_empty/1, len/1, to_list/1, from_list/1,
- in/2, in/3, out/1, join/2, filter/2, fold/3]).
+ in/2, in/3, out/1, join/2, filter/2, fold/3, highest/1]).
%%----------------------------------------------------------------------------
@@ -66,6 +66,7 @@
-spec(join/2 :: (pqueue(), pqueue()) -> pqueue()).
-spec(filter/2 :: (fun ((any()) -> boolean()), pqueue()) -> pqueue()).
-spec(fold/3 :: (fun ((any(), any()) -> any()), any(), pqueue()) -> any()).
+-spec(highest/1 :: (pqueue()) -> priority()).
-endif.
@@ -211,6 +212,9 @@ fold(Fun, Init, Q) -> case out_p(Q) of
{{value, V, P}, Q1} -> fold(Fun, Fun(V, P, Init), Q1)
end.
+highest({queue, _, _, _}) -> 0;
+highest({pqueue, [{P, _} | _]}) -> maybe_negate_priority(P).
+
r2f([], 0) -> {queue, [], [], 0};
r2f([_] = R, 1) -> {queue, [], R, 1};
r2f([X,Y], 2) -> {queue, [X], [Y], 2};
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index e3eeded918..60b56aeb07 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -550,10 +550,7 @@ notify_federation(#q{q = Q,
false -> rabbit_federation_queue:stop(Q)
end.
-active_unfederated(Cs) ->
- %% TODO could this be faster?
- lists:any(fun ({Priority, _Consumer}) -> Priority < 0 end,
- priority_queue:to_list(Cs)).
+active_unfederated(Cs) -> priority_queue:highest(Cs) >= 0.
consumer_priority({_ChPid, #consumer{args = Args}}) ->
case rabbit_misc:table_lookup(Args, <<"x-priority">>) of