From 5be658a8817b8092a7b53b116f622412a5d0aef6 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 8 Nov 2006 17:07:44 +0000 Subject: More reorg to separate APR/posix code, work in progress. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@472545 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/TopicExchange.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'cpp/src/qpid/broker/TopicExchange.cpp') diff --git a/cpp/src/qpid/broker/TopicExchange.cpp b/cpp/src/qpid/broker/TopicExchange.cpp index dc252d208f..eecd9918d4 100644 --- a/cpp/src/qpid/broker/TopicExchange.cpp +++ b/cpp/src/qpid/broker/TopicExchange.cpp @@ -21,7 +21,7 @@ using namespace qpid::broker; using namespace qpid::framing; - +using namespace qpid::sys; // TODO aconway 2006-09-20: More efficient matching algorithm. // Areas for improvement: @@ -115,15 +115,14 @@ bool TopicPattern::match(const Tokens& target) const TopicExchange::TopicExchange(const string& _name) : Exchange(_name) { } void TopicExchange::bind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ - lock.acquire(); + Monitor::ScopedLock l(lock); TopicPattern routingPattern(routingKey); bindings[routingPattern].push_back(queue); queue->bound(new ExchangeBinding(this, queue, routingKey, args)); - lock.release(); } void TopicExchange::unbind(Queue::shared_ptr queue, const string& routingKey, FieldTable* /*args*/){ - lock.acquire(); + Monitor::ScopedLock l(lock); BindingMap::iterator bi = bindings.find(TopicPattern(routingKey)); Queue::vector& qv(bi->second); if (bi == bindings.end()) return; @@ -131,12 +130,11 @@ void TopicExchange::unbind(Queue::shared_ptr queue, const string& routingKey, Fi if(q == qv.end()) return; qv.erase(q); if(qv.empty()) bindings.erase(bi); - lock.release(); } void TopicExchange::route(Deliverable& msg, const string& routingKey, FieldTable* /*args*/){ - lock.acquire(); + Monitor::ScopedLock l(lock); for (BindingMap::iterator i = bindings.begin(); i != bindings.end(); ++i) { if (i->first.match(routingKey)) { Queue::vector& qv(i->second); @@ -145,7 +143,6 @@ void TopicExchange::route(Deliverable& msg, const string& routingKey, FieldTable } } } - lock.release(); } TopicExchange::~TopicExchange() {} -- cgit v1.2.1