activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r742567 - in /activemq/activemq-cpp/trunk/src/main/activemq/state: ConsumerState.cpp ConsumerState.h ProducerState.cpp ProducerState.h SessionState.cpp SessionState.h TransactionState.cpp TransactionState.h
Date Mon, 09 Feb 2009 15:38:31 GMT
Author: tabish
Date: Mon Feb  9 15:38:30 2009
New Revision: 742567

URL: http://svn.apache.org/viewvc?rev=742567&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-100

Refine the State Tracker classes to use smart pointers to avoid numerous copies of the state
data in the Collections that are maintained.

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

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ConsumerState.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/ConsumerState.cpp?rev=742567&r1=742566&r2=742567&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/ConsumerState.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/ConsumerState.cpp Mon Feb  9 15:38:30
2009
@@ -19,11 +19,11 @@
 
 using namespace activemq;
 using namespace activemq::state;
+using namespace activemq::commands;
+using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
-ConsumerState::ConsumerState( const commands::ConsumerInfo* info ) {
-
-    this->info.reset( info->cloneDataStructure() );
+ConsumerState::ConsumerState( const Pointer<ConsumerInfo>& info ) : info( info
) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -33,7 +33,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 std::string ConsumerState::toString() const {
 
-    if( this->info.get() != NULL ) {
+    if( this->info != NULL ) {
         return this->info->toString();
     }
 

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ConsumerState.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/ConsumerState.h?rev=742567&r1=742566&r2=742567&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/ConsumerState.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/ConsumerState.h Mon Feb  9 15:38:30
2009
@@ -21,6 +21,7 @@
 #include <activemq/util/Config.h>
 
 #include <activemq/commands/ConsumerInfo.h>
+#include <decaf/lang/Pointer.h>
 
 #include <string>
 #include <memory>
@@ -28,22 +29,26 @@
 namespace activemq {
 namespace state {
 
+    using namespace decaf::lang;
+    using namespace activemq::commands;
+
     class AMQCPP_API ConsumerState {
     private:
 
-        std::auto_ptr<commands::ConsumerInfo> info;
+        Pointer<ConsumerInfo> info;
 
     public:
 
-        ConsumerState( const commands::ConsumerInfo* );
+        ConsumerState( const Pointer<ConsumerInfo>& info );
 
         virtual ~ConsumerState();
 
         std::string toString() const;
 
-        const commands::ConsumerInfo* getInfo() const {
-            return this->info.get();
+        const Pointer<ConsumerInfo>& getInfo() const {
+            return this->info;
         }
+
     };
 
 }}

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ProducerState.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/ProducerState.cpp?rev=742567&r1=742566&r2=742567&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/ProducerState.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/ProducerState.cpp Mon Feb  9 15:38:30
2009
@@ -19,11 +19,11 @@
 
 using namespace activemq;
 using namespace activemq::state;
+using namespace activemq::commands;
+using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
-ProducerState::ProducerState( const commands::ProducerInfo* info ) {
-
-    this->info.reset( info->cloneDataStructure() );
+ProducerState::ProducerState( const Pointer<ProducerInfo>& info ) : info( info
) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -33,7 +33,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 std::string ProducerState::toString() const {
 
-    if( this->info.get() != NULL ) {
+    if( this->info != NULL ) {
         return this->info->toString();
     }
 

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ProducerState.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/ProducerState.h?rev=742567&r1=742566&r2=742567&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/ProducerState.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/ProducerState.h Mon Feb  9 15:38:30
2009
@@ -21,6 +21,7 @@
 #include <activemq/util/Config.h>
 
 #include <activemq/commands/ProducerInfo.h>
+#include <decaf/lang/Pointer.h>
 
 #include <string>
 #include <memory>
@@ -28,21 +29,24 @@
 namespace activemq {
 namespace state {
 
+    using namespace decaf::lang;
+    using namespace activemq::commands;
+
     class AMQCPP_API ProducerState {
     private:
 
-        std::auto_ptr<commands::ProducerInfo> info;
+        Pointer<ProducerInfo> info;
 
     public:
 
-        ProducerState( const commands::ProducerInfo* info );
+        ProducerState( const Pointer<ProducerInfo>& info );
 
         virtual ~ProducerState();
 
         std::string toString() const;
 
-        const commands::ProducerInfo* getInfo() const {
-            return this->info.get();
+        const Pointer<ProducerInfo>& getInfo() const {
+            return this->info;
         }
 
     };

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.cpp?rev=742567&r1=742566&r2=742567&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.cpp Mon Feb  9 15:38:30
2009
@@ -21,11 +21,13 @@
 
 using namespace activemq;
 using namespace activemq::state;
+using namespace activemq::commands;
+using namespace decaf;
+using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
-SessionState::SessionState( const commands::SessionInfo* info ) : disposed( false ) {
-
-    this->info.reset( info->cloneDataStructure() );
+SessionState::SessionState( const Pointer<SessionInfo>& info ) :
+    disposed( false ), info( info ) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.h?rev=742567&r1=742566&r2=742567&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.h Mon Feb  9 15:38:30
2009
@@ -34,24 +34,34 @@
 namespace activemq {
 namespace state {
 
+    using namespace activemq::commands;
+    using namespace decaf::lang;
+
     class AMQCPP_API SessionState {
     private:
 
-        std::auto_ptr<commands::SessionInfo> info;
-        decaf::util::Map< commands::ProducerId, ProducerState* > producers;
-        decaf::util::Map< commands::ConsumerId, ConsumerState* > consumers;
+        Pointer<SessionInfo> info;
+
+        decaf::util::Map< Pointer<ProducerId>,
+                          Pointer<ProducerState>,
+                          ProducerId::COMPARATOR > producers;
+
+        decaf::util::Map< Pointer<ConsumerId>,
+                          Pointer<ConsumerState>,
+                          ConsumerId::COMPARATOR > consumers;
+
         decaf::util::concurrent::atomic::AtomicBoolean disposed;
 
     public:
 
-        SessionState( const commands::SessionInfo* info );
+        SessionState( const Pointer<SessionInfo>& info );
 
         virtual ~SessionState();
 
         std::string toString() const;
 
-        const commands::SessionInfo* getInfo() const {
-            return this->info.get();
+        const Pointer<SessionInfo> getInfo() const {
+            return this->info;
         }
 
 //        void addProducer(commands::ProducerInfo info) {

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/TransactionState.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/TransactionState.cpp?rev=742567&r1=742566&r2=742567&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/TransactionState.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/TransactionState.cpp Mon Feb  9 15:38:30
2009
@@ -20,26 +20,21 @@
 #include <decaf/lang/exceptions/IllegalStateException.h>
 
 using namespace activemq;
+using namespace activemq::commands;
 using namespace activemq::state;
 using namespace decaf;
 using namespace decaf::util;
+using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
-TransactionState::TransactionState( const commands::TransactionId* id ) : disposed( false
) {
-
-    this->id.reset( id->cloneDataStructure() );
-    this->prepared = false;
-    this->preparedResult = 0;
+TransactionState::TransactionState( const Pointer<TransactionId>& id ) :
+    disposed( false ), id( id ), prepared( false ), preparedResult( 0 ) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 TransactionState::~TransactionState() {
 
-    std::auto_ptr< Iterator<commands::Command*> > iter( this->commands.iterator()
);
-
-    while( iter->hasNext() ) {
-        delete iter->next();
-    }
+    this->commands.clear();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -53,12 +48,10 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TransactionState::addCommand( commands::Command* operation ) {
+void TransactionState::addCommand( const Pointer<Command>& operation ) {
 
     checkShutdown();
-
-    commands.add(
-        dynamic_cast<commands::Command*>( operation->cloneDataStructure() ) );
+    commands.add( operation );
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/TransactionState.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/TransactionState.h?rev=742567&r1=742566&r2=742567&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/TransactionState.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/TransactionState.h Mon Feb  9 15:38:30
2009
@@ -22,6 +22,7 @@
 #include <activemq/commands/Command.h>
 #include <activemq/commands/TransactionId.h>
 
+#include <decaf/lang/Pointer.h>
 #include <decaf/util/List.h>
 #include <decaf/util/concurrent/atomic/AtomicBoolean.h>
 
@@ -34,21 +35,21 @@
     class AMQCPP_API TransactionState {
     private:
 
-        decaf::util::List<commands::Command*> commands;
-        std::auto_ptr<commands::TransactionId> id;
+        decaf::util::List< decaf::lang::Pointer<commands::Command> > commands;
+        decaf::lang::Pointer<commands::TransactionId> id;
         decaf::util::concurrent::atomic::AtomicBoolean disposed;
         bool prepared;
         int preparedResult;
 
     public:
 
-        TransactionState( const commands::TransactionId* id );
+        TransactionState( const decaf::lang::Pointer<commands::TransactionId>&
id );
 
         virtual ~TransactionState();
 
         std::string toString() const;
 
-        void addCommand( commands::Command* operation );
+        void addCommand( const decaf::lang::Pointer< commands::Command >& operation
);
 
         void checkShutdown() const;
 
@@ -56,12 +57,12 @@
             this->disposed.set( true );
         }
 
-        const decaf::util::List<commands::Command*>& getCommands() {
+        const decaf::util::List<decaf::lang::Pointer< commands::Command > >&
getCommands() {
             return commands;
         }
 
-        const commands::TransactionId* getId() const {
-            return id.get();
+        const decaf::lang::Pointer<commands::TransactionId>& getId() const {
+            return id;
         }
 
         void setPrepared( bool prepared ) {



Mime
View raw message