You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2008/08/20 16:45:19 UTC

svn commit: r687361 - in /incubator/qpid/trunk/qpid/cpp/src/qpid/broker: Queue.cpp Queue.h

Author: gsim
Date: Wed Aug 20 07:45:19 2008
New Revision: 687361

URL: http://svn.apache.org/viewvc?rev=687361&view=rev
Log:
Remove 'clever' locking as it actually degrades performance.


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp?rev=687361&r1=687360&r2=687361&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp Wed Aug 20 07:45:19 2008
@@ -307,18 +307,12 @@
 
     Listeners copy(listeners);
     listeners.clear();
-
-    sys::ScopedLock<Guard> g(notifierLock);//prevent consumers being deleted while held in copy
-    {
-        Mutex::ScopedUnlock u(messageLock);
-        for_each(copy.begin(), copy.end(), mem_fun(&Consumer::notify));
-    }
+    for_each(copy.begin(), copy.end(), mem_fun(&Consumer::notify));
 }
 
 void Queue::removeListener(Consumer& c)
 {
     Mutex::ScopedLock locker(messageLock);
-    notifierLock.wait(messageLock);//wait until no notifies are in progress 
     Listeners::iterator i = std::find(listeners.begin(), listeners.end(), &c);
     if (i != listeners.end()) listeners.erase(i);
 }
@@ -722,27 +716,6 @@
     }
 }
 
-/*
- * Use of Guard requires an external lock to be held before calling
- * any of its methods
- */
-Queue::Guard::Guard() : count(0) {}
-
-void Queue::Guard::lock()
-{
-    count++;
-}
-
-void Queue::Guard::unlock()
-{
-    if (--count == 0) condition.notifyAll();
-}
-
-void Queue::Guard::wait(sys::Mutex& m)
-{
-    while (count) condition.wait(m);
-}
-
 ManagementObject* Queue::GetManagementObject (void) const
 {
     return (ManagementObject*) mgmtObject;

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h?rev=687361&r1=687360&r2=687361&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.h Wed Aug 20 07:45:19 2008
@@ -63,17 +63,6 @@
             typedef qpid::InlineVector<Consumer*, 5> Listeners;
             typedef std::deque<QueuedMessage> Messages;
 
-            class Guard 
-            {
-                qpid::sys::Condition condition;
-                size_t count;
-              public:
-                Guard();
-                void lock();
-                void unlock();
-                void wait(sys::Mutex&);
-            };
-
             const string name;
             const bool autodelete;
             MessageStore* store;
@@ -88,7 +77,6 @@
             mutable qpid::sys::Mutex consumerLock;
             mutable qpid::sys::Mutex messageLock;
             mutable qpid::sys::Mutex ownershipLock;
-            Guard notifierLock;
             mutable uint64_t persistenceId;
             framing::FieldTable settings;
             std::auto_ptr<QueuePolicy> policy;