activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1341675 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state: ConnectionState.cpp ConnectionState.h SessionState.cpp SessionState.h TransactionState.cpp TransactionState.h
Date Tue, 22 May 2012 23:06:23 GMT
Author: tabish
Date: Tue May 22 23:06:22 2012
New Revision: 1341675

URL: http://svn.apache.org/viewvc?rev=1341675&view=rev
Log:
Some additional State tracker code cleanup

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.cpp?rev=1341675&r1=1341674&r2=1341675&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.cpp Tue
May 22 23:06:22 2012
@@ -28,13 +28,8 @@ using namespace activemq::commands;
 
 ////////////////////////////////////////////////////////////////////////////////
 ConnectionState::ConnectionState(Pointer<ConnectionInfo> info) :
-    info(info),
-    transactions(),
-    sessions(),
-    tempDestinations(),
-    disposed(false),
-    connectionInterruptProcessingComplete(true),
-    recoveringPullConsumers() {
+    info(info), transactions(), sessions(), tempDestinations(), disposed(false),
+    connectionInterruptProcessingComplete(true), recoveringPullConsumers() {
 
     Pointer<SessionId> sessionId(new SessionId(info->getConnectionId().get(), -1));
     Pointer<SessionInfo> session(new SessionInfo());
@@ -46,6 +41,9 @@ ConnectionState::ConnectionState(Pointer
 
 ////////////////////////////////////////////////////////////////////////////////
 ConnectionState::~ConnectionState() {
+    transactions.clear();
+    sessions.clear();
+    tempDestinations.clear();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -83,9 +81,21 @@ void ConnectionState::shutdown() {
 
 ////////////////////////////////////////////////////////////////////////////////
 void ConnectionState::checkShutdown() const {
-
     if (this->disposed.get()) {
         throw decaf::lang::exceptions::IllegalStateException(
             __FILE__, __LINE__, "Connection already Disposed");
     }
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void ConnectionState::removeTempDestination(Pointer<ActiveMQDestination> destination)
{
+
+    std::auto_ptr<decaf::util::Iterator<Pointer<DestinationInfo> > > iter(tempDestinations.iterator());
+
+    while (iter->hasNext()) {
+        Pointer<DestinationInfo> di = iter->next();
+        if (di->getDestination()->equals(destination.get())) {
+            iter->remove();
+        }
+    }
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.h?rev=1341675&r1=1341674&r2=1341675&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/ConnectionState.h Tue
May 22 23:06:22 2012
@@ -88,17 +88,7 @@ namespace state {
             tempDestinations.add(info);
         }
 
-        void removeTempDestination(Pointer<ActiveMQDestination> destination) {
-
-            std::auto_ptr<decaf::util::Iterator<Pointer<DestinationInfo> >
> iter(tempDestinations.iterator());
-
-            while (iter->hasNext()) {
-                Pointer<DestinationInfo> di = iter->next();
-                if (di->getDestination()->equals(destination.get())) {
-                    iter->remove();
-                }
-            }
-        }
+        void removeTempDestination(Pointer<ActiveMQDestination> destination);
 
         void addTransactionState(Pointer<TransactionId> id) {
             checkShutdown();

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.cpp?rev=1341675&r1=1341674&r2=1341675&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.cpp Tue
May 22 23:06:22 2012
@@ -34,6 +34,10 @@ SessionState::SessionState(Pointer<Sessi
 
 ////////////////////////////////////////////////////////////////////////////////
 SessionState::~SessionState() {
+    try {
+        this->shutdown();
+    }
+    DECAF_CATCHALL_NOTHROW()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -47,8 +51,14 @@ std::string SessionState::toString() con
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void SessionState::checkShutdown() const {
+void SessionState::shutdown() {
+    this->disposed.set(true);
+    this->producers.clear();
+    this->consumers.clear();
+}
 
+////////////////////////////////////////////////////////////////////////////////
+void SessionState::checkShutdown() const {
     if (this->disposed.get()) {
         throw decaf::lang::exceptions::IllegalStateException(
             __FILE__, __LINE__, "Session already Disposed");
@@ -63,7 +73,6 @@ void SessionState::addProducer(Pointer<P
 
 ////////////////////////////////////////////////////////////////////////////////
 Pointer<ProducerState> SessionState::removeProducer(Pointer<ProducerId> id) {
-
     Pointer<ProducerState> producerState = producers.remove(id);
     if (producerState != NULL) {
         if (producerState->getTransactionState() != NULL) {
@@ -77,3 +86,14 @@ Pointer<ProducerState> SessionState::rem
 
     return producerState;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void SessionState::addConsumer(Pointer<ConsumerInfo> info) {
+    checkShutdown();
+    consumers.put(info->getConsumerId(), Pointer<ConsumerState>(new ConsumerState(info)));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Pointer<ConsumerState> SessionState::removeConsumer(Pointer<ConsumerId> id) {
+    return consumers.remove(id);
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.h?rev=1341675&r1=1341674&r2=1341675&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/SessionState.h Tue May
22 23:06:22 2012
@@ -75,14 +75,9 @@ namespace state {
 
         Pointer<ProducerState> removeProducer(Pointer<ProducerId> id);
 
-        void addConsumer(const Pointer<ConsumerInfo>& info) {
-            checkShutdown();
-            consumers.put(info->getConsumerId(), Pointer<ConsumerState>(new ConsumerState(info)));
-        }
+        void addConsumer(Pointer<ConsumerInfo> info);
 
-        Pointer<ConsumerState> removeConsumer(Pointer<ConsumerId> id) {
-            return consumers.remove(id);
-        }
+        Pointer<ConsumerState> removeConsumer(Pointer<ConsumerId> id);
 
         std::vector<Pointer<ProducerState> > getProducerStates() const {
             return producers.values();
@@ -102,9 +97,7 @@ namespace state {
 
         void checkShutdown() const;
 
-        void shutdown() {
-            this->disposed.set(true);
-        }
+        void shutdown();
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.cpp?rev=1341675&r1=1341674&r2=1341675&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.cpp
Tue May 22 23:06:22 2012
@@ -35,7 +35,10 @@ TransactionState::TransactionState(Point
 
 ////////////////////////////////////////////////////////////////////////////////
 TransactionState::~TransactionState() {
-    clear();
+    try {
+        clear();
+    }
+    DECAF_CATCHALL_NOTHROW()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -49,6 +52,12 @@ std::string TransactionState::toString()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void TransactionState::shutdown() {
+    this->disposed.set(true);
+    this->clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void TransactionState::clear() {
     this->commands.clear();
     this->producers.clear();
@@ -56,14 +65,12 @@ void TransactionState::clear() {
 
 ////////////////////////////////////////////////////////////////////////////////
 void TransactionState::addCommand(Pointer<Command> operation) {
-
     checkShutdown();
     commands.add(operation);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void TransactionState::checkShutdown() const {
-
     if (this->disposed.get()) {
         throw decaf::lang::exceptions::IllegalStateException(
             __FILE__, __LINE__, "Transaction already Disposed");
@@ -72,7 +79,6 @@ void TransactionState::checkShutdown() c
 
 ////////////////////////////////////////////////////////////////////////////////
 void TransactionState::addProducerState(Pointer<ProducerState> producerState) {
-
     if (producerState != NULL) {
         // Ensure the producer doesn't hold a link to this TX state to avoid a
         // circular reference that could lead to memory leaks.

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.h?rev=1341675&r1=1341674&r2=1341675&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/state/TransactionState.h Tue
May 22 23:06:22 2012
@@ -70,9 +70,7 @@ namespace state {
 
         void checkShutdown() const;
 
-        void shutdown() {
-            this->disposed.set(true);
-        }
+        void shutdown();
 
         void clear();
 



Mime
View raw message