activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1327683 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover: CloseTransportsTask.cpp CloseTransportsTask.h
Date Wed, 18 Apr 2012 21:07:35 GMT
Author: tabish
Date: Wed Apr 18 21:07:34 2012
New Revision: 1327683

URL: http://svn.apache.org/viewvc?rev=1327683&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQCPP-376

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.cpp?rev=1327683&r1=1327682&r2=1327683&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.cpp
Wed Apr 18 21:07:34 2012
@@ -30,7 +30,8 @@ using namespace decaf::util;
 using namespace decaf::util::concurrent;
 
 ////////////////////////////////////////////////////////////////////////////////
-CloseTransportsTask::CloseTransportsTask() : transports() {
+CloseTransportsTask::CloseTransportsTask() :
+    transports() {
 
 }
 
@@ -40,42 +41,31 @@ CloseTransportsTask::~CloseTransportsTas
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void CloseTransportsTask::add( const Pointer<Transport>& transport ) {
-    synchronized( &transports ) {
-        transports.push( transport );
-    }
+void CloseTransportsTask::add(const Pointer<Transport>& transport) {
+    transports.put(transport);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 bool CloseTransportsTask::isPending() const {
-
     bool result = false;
-
-    synchronized( &transports ) {
-        result = !transports.isEmpty();
-    }
-
+    result = !transports.isEmpty();
     return result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 bool CloseTransportsTask::iterate() {
 
-    synchronized( &transports ) {
+    if (!transports.isEmpty()) {
+        Pointer<Transport> transport = transports.take();
 
-        if( !transports.isEmpty() ) {
-            Pointer<Transport> transport = transports.pop();
-
-            try{
-                transport->close();
-            }
-            AMQ_CATCHALL_NOTHROW()
-
-            transport.reset( NULL );
-
-            return !transports.isEmpty();
+        try {
+            transport->close();
         }
+        AMQ_CATCHALL_NOTHROW()
+
+        transport.reset(NULL);
 
+        return !transports.isEmpty();
     }
 
     return false;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.h?rev=1327683&r1=1327682&r2=1327683&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/CloseTransportsTask.h
Wed Apr 18 21:07:34 2012
@@ -22,7 +22,7 @@
 #include <activemq/threads/CompositeTask.h>
 #include <activemq/transport/Transport.h>
 
-#include <decaf/util/LinkedList.h>
+#include <decaf/util/concurrent/LinkedBlockingQueue.h>
 #include <decaf/lang/Pointer.h>
 
 namespace activemq {
@@ -30,12 +30,11 @@ namespace transport {
 namespace failover {
 
     using decaf::lang::Pointer;
-    using decaf::util::LinkedList;
 
     class AMQCPP_API CloseTransportsTask: public activemq::threads::CompositeTask {
     private:
 
-        mutable LinkedList< Pointer<Transport> > transports;
+        mutable decaf::util::concurrent::LinkedBlockingQueue< Pointer<Transport>
> transports;
 
     public:
 
@@ -46,7 +45,7 @@ namespace failover {
         /**
          * Add a new Transport to close.
          */
-        void add( const Pointer<Transport>& transport );
+        void add(const Pointer<Transport>& transport);
 
         /**
          * This Task is pending if there are transports in the Queue that need to be



Mime
View raw message