summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qpid/cpp/src/qpid/broker/QueueListeners.cpp26
-rw-r--r--qpid/cpp/src/qpid/broker/QueueListeners.h8
2 files changed, 9 insertions, 25 deletions
diff --git a/qpid/cpp/src/qpid/broker/QueueListeners.cpp b/qpid/cpp/src/qpid/broker/QueueListeners.cpp
index 7baca7d0f4..5b2c898294 100644
--- a/qpid/cpp/src/qpid/broker/QueueListeners.cpp
+++ b/qpid/cpp/src/qpid/broker/QueueListeners.cpp
@@ -27,43 +27,31 @@ namespace broker {
void QueueListeners::addListener(Consumer::shared_ptr c)
{
if (c->preAcquires()) {
- add(consumers, c);
+ consumers.insert(c);
} else {
- add(browsers, c);
+ browsers.insert(c);
}
}
void QueueListeners::removeListener(Consumer::shared_ptr c)
{
if (c->preAcquires()) {
- remove(consumers, c);
+ consumers.erase(c);
} else {
- remove(browsers, c);
+ browsers.erase(c);
}
}
void QueueListeners::populate(NotificationSet& set)
{
- if (consumers.size()) {
- set.consumer = consumers.front();
- consumers.pop_front();
+ if (!consumers.empty()) {
+ set.consumer = *consumers.begin();
+ consumers.erase(consumers.begin());
} else {
browsers.swap(set.browsers);
}
}
-void QueueListeners::add(Listeners& listeners, Consumer::shared_ptr c)
-{
- Listeners::iterator i = std::find(listeners.begin(), listeners.end(), c);
- if (i == listeners.end()) listeners.push_back(c);
-}
-
-void QueueListeners::remove(Listeners& listeners, Consumer::shared_ptr c)
-{
- Listeners::iterator i = std::find(listeners.begin(), listeners.end(), c);
- if (i != listeners.end()) listeners.erase(i);
-}
-
void QueueListeners::NotificationSet::notify()
{
if (consumer) consumer->notify();
diff --git a/qpid/cpp/src/qpid/broker/QueueListeners.h b/qpid/cpp/src/qpid/broker/QueueListeners.h
index 53ed6a17e4..509f1be6f3 100644
--- a/qpid/cpp/src/qpid/broker/QueueListeners.h
+++ b/qpid/cpp/src/qpid/broker/QueueListeners.h
@@ -22,7 +22,7 @@
*
*/
#include "Consumer.h"
-#include <list>
+#include <set>
namespace qpid {
namespace broker {
@@ -40,7 +40,7 @@ namespace broker {
class QueueListeners
{
public:
- typedef std::list<Consumer::shared_ptr> Listeners;
+ typedef std::set<Consumer::shared_ptr> Listeners;
class NotificationSet
{
@@ -58,10 +58,6 @@ class QueueListeners
private:
Listeners consumers;
Listeners browsers;
-
- void add(Listeners&, Consumer::shared_ptr);
- void remove(Listeners&, Consumer::shared_ptr);
-
};
}} // namespace qpid::broker