qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r676932 - in /incubator/qpid/trunk/qpid/cpp/src: ./ qpid/broker/ tests/
Date Tue, 15 Jul 2008 14:59:38 GMT
Author: aconway
Date: Tue Jul 15 07:59:37 2008
New Revision: 676932

URL: http://svn.apache.org/viewvc?rev=676932&view=rev
Log:
Switched from shared_ptr to intrusive_ptr and RefCounted for Broker.

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.h
    incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp
    incubator/qpid/trunk/qpid/cpp/src/tests/BrokerFixture.h
    incubator/qpid/trunk/qpid/cpp/src/tests/ForkedBroker.h

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp?rev=676932&r1=676931&r2=676932&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp Tue Jul 15 07:59:37 2008
@@ -240,16 +240,16 @@
 }
 
 
-shared_ptr<Broker> Broker::create(int16_t port) 
+boost::intrusive_ptr<Broker> Broker::create(int16_t port) 
 {
     Options config;
     config.port=port;
     return create(config);
 }
 
-shared_ptr<Broker> Broker::create(const Options& opts) 
+boost::intrusive_ptr<Broker> Broker::create(const Options& opts) 
 {
-    return shared_ptr<Broker>(new Broker(opts));
+    return boost::intrusive_ptr<Broker>(new Broker(opts));
 }
 
 void Broker::setStore (MessageStore* _store)

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h?rev=676932&r1=676931&r2=676932&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h Tue Jul 15 07:59:37 2008
@@ -44,7 +44,9 @@
 #include "qpid/framing/OutputHandler.h"
 #include "qpid/framing/ProtocolInitiation.h"
 #include "qpid/sys/Runnable.h"
+#include "qpid/RefCounted.h"
 
+#include <boost/intrusive_ptr.hpp>
 #include <vector>
 
 namespace qpid { 
@@ -64,7 +66,7 @@
  * A broker instance. 
  */
 class Broker : public sys::Runnable, public Plugin::Target,
-               public management::Manageable
+               public management::Manageable, public RefCounted
 {
   public:
 
@@ -89,8 +91,8 @@
     virtual ~Broker();
 
     Broker(const Options& configuration);
-    static shared_ptr<Broker> create(const Options& configuration);
-    static shared_ptr<Broker> create(int16_t port = DEFAULT_PORT);
+    static boost::intrusive_ptr<Broker> create(const Options& configuration);
+    static boost::intrusive_ptr<Broker> create(int16_t port = DEFAULT_PORT);
 
     /**
      * Return listening port. If called before bind this is

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.cpp?rev=676932&r1=676931&r2=676932&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.cpp Tue Jul 15 07:59:37
2008
@@ -24,13 +24,13 @@
 BrokerSingleton::BrokerSingleton() {
     if (broker.get() == 0)
         broker = Broker::create();
-    shared_ptr<Broker>::operator=(broker);
+    boost::intrusive_ptr<Broker>::operator=(broker);
 }
 
 BrokerSingleton::~BrokerSingleton() {
     broker->shutdown();
 }
 
-shared_ptr<Broker> BrokerSingleton::broker;
+boost::intrusive_ptr<Broker> BrokerSingleton::broker;
 
 }} // namespace qpid::broker

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.h?rev=676932&r1=676931&r2=676932&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerSingleton.h Tue Jul 15 07:59:37 2008
@@ -36,13 +36,13 @@
  *
  * THREAD UNSAFE.
  */
-class BrokerSingleton : public shared_ptr<Broker>
+class BrokerSingleton : public boost::intrusive_ptr<Broker>
 {
   public:
     BrokerSingleton();
     ~BrokerSingleton();
   private:
-    static shared_ptr<Broker> broker;
+    static boost::intrusive_ptr<Broker> broker;
 };
 
 }} // namespace qpid::broker

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.cpp?rev=676932&r1=676931&r2=676932&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.cpp Tue Jul 15 07:59:37 2008
@@ -25,9 +25,9 @@
 namespace qpid {
 namespace broker {
 
-boost::shared_ptr<Broker> SignalHandler::broker;
+boost::intrusive_ptr<Broker> SignalHandler::broker;
 
-void SignalHandler::setBroker(const boost::shared_ptr<Broker>& b) {
+void SignalHandler::setBroker(const boost::intrusive_ptr<Broker>& b) {
     broker = b;
 
     signal(SIGINT,shutdownHandler); 
@@ -44,7 +44,7 @@
 void SignalHandler::shutdownHandler(int) {
     if (broker.get()) {
         broker->shutdown();
-        broker.reset();
+        broker = 0;             // Release the broker reference.
     }
 }
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.h?rev=676932&r1=676931&r2=676932&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SignalHandler.h Tue Jul 15 07:59:37 2008
@@ -22,7 +22,7 @@
  *
  */
 
-#include <boost/shared_ptr.hpp>
+#include <boost/intrusive_ptr.hpp>
 
 namespace qpid {
 namespace broker {
@@ -36,11 +36,11 @@
 {
   public:
     /** Set the broker to be shutdown on signals */
-    static void setBroker(const boost::shared_ptr<Broker>& broker);
+    static void setBroker(const boost::intrusive_ptr<Broker>& broker);
 
   private:
     static void shutdownHandler(int);
-    static boost::shared_ptr<Broker> broker;
+    static boost::intrusive_ptr<Broker> broker;
 };
 }} // namespace qpid::broker
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp?rev=676932&r1=676931&r2=676932&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp Tue Jul 15 07:59:37 2008
@@ -142,7 +142,7 @@
 
     /** Code for forked child process */
     void child() {
-        shared_ptr<Broker> brokerPtr(new Broker(options->broker));
+        boost::intrusive_ptr<Broker> brokerPtr(new Broker(options->broker));
         broker::SignalHandler::setBroker(brokerPtr);
         uint16_t port=brokerPtr->getPort();
         ready(port);            // Notify parent.
@@ -244,7 +244,7 @@
             d.fork();           // Broker is stared in QpiddDaemon::child()
         } 
         else {                  // Non-daemon broker.
-            shared_ptr<Broker> brokerPtr(new Broker(options->broker));
+            boost::intrusive_ptr<Broker> brokerPtr(new Broker(options->broker));
             broker::SignalHandler::setBroker(brokerPtr);
             if (options->broker.port == 0)
                 cout << uint16_t(brokerPtr->getPort()) << endl; 

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/BrokerFixture.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/BrokerFixture.h?rev=676932&r1=676931&r2=676932&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/BrokerFixture.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/BrokerFixture.h Tue Jul 15 07:59:37 2008
@@ -36,7 +36,7 @@
  */
 struct  BrokerFixture : private boost::noncopyable {
     typedef qpid::broker::Broker Broker;
-    typedef boost::shared_ptr<Broker> BrokerPtr;
+    typedef boost::intrusive_ptr<Broker> BrokerPtr;
 
     BrokerPtr broker;
     qpid::sys::Thread brokerThread;

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/ForkedBroker.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/ForkedBroker.h?rev=676932&r1=676931&r2=676932&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/ForkedBroker.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/ForkedBroker.h Tue Jul 15 07:59:37 2008
@@ -91,7 +91,7 @@
         prefix += boost::lexical_cast<std::string>(long(getpid()));
         qpid::log::Logger::instance().setPrefix(prefix);
         opts.port = 0;
-        boost::shared_ptr<qpid::broker::Broker> broker(new qpid::broker::Broker(opts));
+        boost::intrusive_ptr<qpid::broker::Broker> broker(new qpid::broker::Broker(opts));
         qpid::broker::SignalHandler::setBroker(broker);
         QPID_LOG(info, "ForkedBroker started on " << broker->getPort());
         ready(boost::lexical_cast<std::string>(broker->getPort())); // Notify parent.
@@ -99,8 +99,8 @@
         QPID_LOG(notice, "ForkedBroker exiting.");
 
         // Force exit in the child process, otherwise we will try to
-        // carry with parent tests.
-        broker.reset();         // Run broker dtor before we exit.
+        // carry with parent tests. 
+        broker = 0;             // Run broker dtor before we exit.
         exit(0);
     }
 



Mime
View raw message