You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2008/07/09 22:36:18 UTC

svn commit: r675338 - in /incubator/qpid/trunk/qpid/cpp/src/qpid: client/ sys/ sys/posix/

Author: astitcher
Date: Wed Jul  9 13:36:17 2008
New Revision: 675338

URL: http://svn.apache.org/viewvc?rev=675338&view=rev
Log:
Some small changes which clean up header file inclusions
and generally start to tidy up the network layer so that it's
a bit easier to implement new network transports

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connector.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.h?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.h Wed Jul  9 13:36:17 2008
@@ -23,7 +23,6 @@
  */
 #include <map>
 #include <string>
-#include "ConnectionImpl.h"
 #include "qpid/client/Session.h"
 
 namespace qpid {

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp Wed Jul  9 13:36:17 2008
@@ -19,6 +19,7 @@
  *
  */
 #include "ConnectionImpl.h"
+#include "Connector.h"
 #include "ConnectionSettings.h"
 #include "SessionImpl.h"
 
@@ -38,7 +39,7 @@
 ConnectionImpl::ConnectionImpl(framing::ProtocolVersion v, const ConnectionSettings& settings)
     : Bounds(settings.maxFrameSize * settings.bounds),
       handler(settings, v),
-      connector(v, settings, this), 
+      connector(new Connector(v, settings, this)), 
       version(v), 
       isClosed(true),//closed until successfully opened 
       isClosing(false)
@@ -48,9 +49,9 @@
     handler.out = boost::bind(&Connector::send, boost::ref(connector), _1);
     handler.onClose = boost::bind(&ConnectionImpl::closed, this,
                                   NORMAL, std::string());
-    connector.setInputHandler(&handler);
-    connector.setTimeoutHandler(this);
-    connector.setShutdownHandler(this);
+    connector->setInputHandler(&handler);
+    connector->setTimeoutHandler(this);
+    connector->setShutdownHandler(this);
 
     //only set error handler once  open
     handler.onError = boost::bind(&ConnectionImpl::closed, this, _1, _2);
@@ -60,7 +61,7 @@
     // Important to close the connector first, to ensure the
     // connector thread does not call on us while the destructor
     // is running.
-    connector.close(); 
+    connector->close(); 
 }
 
 void ConnectionImpl::addSession(const boost::shared_ptr<SessionImpl>& session)
@@ -97,8 +98,8 @@
 void ConnectionImpl::open(const std::string& host, int port)
 {
     QPID_LOG(info, "Connecting to " << host << ":" << port);
-    connector.connect(host, port);
-    connector.init();
+    connector->connect(host, port);
+    connector->init();
     handler.waitForOpen();    
     Mutex::ScopedLock l(lock);
     isClosed = false;
@@ -112,7 +113,7 @@
 void ConnectionImpl::idleOut()
 {
     AMQFrame frame(in_place<AMQHeartbeatBody>());
-    connector.send(frame);
+    connector->send(frame);
 }
 
 void ConnectionImpl::close()
@@ -130,8 +131,8 @@
 
 template <class F> void ConnectionImpl::closeInternal(const F& f) {
     isClosed = true;
-    connector.close();
-    for (SessionMap::iterator i=sessions.begin(); i != sessions.end(); ++i) {
+    connector->close();
+    for (SessionMap::iterator i = sessions.begin(); i != sessions.end(); ++i) {
         boost::shared_ptr<SessionImpl> s = i->second.lock();
         if (s) f(s);
     }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h Wed Jul  9 13:36:17 2008
@@ -24,7 +24,6 @@
 
 #include "Bounds.h"
 #include "ConnectionHandler.h"
-#include "Connector.h"
 #include "qpid/framing/FrameHandler.h"
 #include "qpid/sys/Mutex.h"
 #include "qpid/sys/ShutdownHandler.h"
@@ -33,11 +32,13 @@
 #include <map>
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
 #include <boost/enable_shared_from_this.hpp>
 
 namespace qpid {
 namespace client {
 
+class Connector;
 class ConnectionSettings;
 class SessionImpl;
 
@@ -52,7 +53,7 @@
 
     SessionMap sessions; 
     ConnectionHandler handler;
-    Connector connector;
+    boost::scoped_ptr<Connector> connector;
     framing::ProtocolVersion version;
     sys::Mutex lock;
     bool isClosed;

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connector.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connector.h?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connector.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connector.h Wed Jul  9 13:36:17 2008
@@ -34,13 +34,18 @@
 #include "qpid/sys/Mutex.h"
 #include "qpid/sys/Socket.h"
 #include "qpid/sys/Time.h"
-#include "qpid/sys/AsynchIO.h"
 
 #include <queue>
 #include <boost/weak_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 
 namespace qpid {
+
+namespace sys {
+class Poller;
+class AsynchIO;
+class AsynchIOBufferBase;
+}
 	
 namespace client {
 
@@ -56,7 +61,7 @@
 
     /** Batch up frames for writing to aio. */
     class Writer : public framing::FrameHandler {
-        typedef sys::AsynchIO::BufferBase BufferBase;
+        typedef sys::AsynchIOBufferBase BufferBase;
         typedef std::vector<framing::AMQFrame> Frames;
 
         const uint16_t maxFrameSize;
@@ -109,7 +114,7 @@
     sys::Socket socket;
 
     sys::AsynchIO* aio;
-    sys::Poller::shared_ptr poller;
+    boost::shared_ptr<sys::Poller> poller;
 
     void checkIdle(ssize_t status);
     void setSocketTimeout();
@@ -118,7 +123,7 @@
     void handleClosed();
     bool closeInternal();
     
-    void readbuff(qpid::sys::AsynchIO&, qpid::sys::AsynchIO::BufferBase*);
+    void readbuff(qpid::sys::AsynchIO&, qpid::sys::AsynchIOBufferBase*);
     void writebuff(qpid::sys::AsynchIO&);
     void writeDataBlock(const framing::AMQDataBlock& data);
     void eof(qpid::sys::AsynchIO&);

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h Wed Jul  9 13:36:17 2008
@@ -22,13 +22,14 @@
  */
 
 #include "Dispatcher.h"
-#include "Socket.h"
 
 #include <boost/function.hpp>
 #include <deque>
 
 namespace qpid {
 namespace sys {
+    
+class Socket;
 
 /*
  * Asynchronous acceptor: accepts connections then does a callback with the
@@ -78,6 +79,23 @@
     void failure(int, std::string);
 };
 
+struct AsynchIOBufferBase {
+    char* const bytes;
+    const int32_t byteCount;
+    int32_t dataStart;
+    int32_t dataCount;
+    
+    AsynchIOBufferBase(char* const b, const int32_t s) :
+        bytes(b),
+        byteCount(s),
+        dataStart(0),
+        dataCount(0)
+    {}
+    
+    virtual ~AsynchIOBufferBase()
+    {}
+};
+
 /*
  * Asychronous reader/writer: 
  * Reader accepts buffers to read into; reads into the provided buffers
@@ -92,22 +110,7 @@
  */
 class AsynchIO : private DispatchHandle {
 public:
-    struct BufferBase {
-        char* const bytes;
-        const int32_t byteCount;
-        int32_t dataStart;
-        int32_t dataCount;
-        
-        BufferBase(char* const b, const int32_t s) :
-            bytes(b),
-            byteCount(s),
-            dataStart(0),
-            dataCount(0)
-        {}
-        
-        virtual ~BufferBase()
-        {}
-    };
+    typedef AsynchIOBufferBase BufferBase;
 
     typedef boost::function2<void, AsynchIO&, BufferBase*> ReadCallback;
     typedef boost::function1<void, AsynchIO&> EofCallback;

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp Wed Jul  9 13:36:17 2008
@@ -20,6 +20,8 @@
  */
 
 #include "AsynchIOHandler.h"
+#include "qpid/sys/AsynchIO.h"
+#include "qpid/sys/Socket.h"
 #include "qpid/framing/AMQP_HighestVersion.h"
 #include "qpid/framing/ProtocolInitiation.h"
 #include "qpid/log/Statement.h"

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h Wed Jul  9 13:36:17 2008
@@ -23,7 +23,6 @@
 
 #include "OutputControl.h"
 #include "ConnectionCodec.h"
-#include "AsynchIO.h"
 
 namespace qpid {
 
@@ -32,6 +31,11 @@
 }
 
 namespace sys {
+
+class AsynchIO;
+class AsynchIOBufferBase;
+class Socket;
+
 class AsynchIOHandler : public OutputControl {
     std::string identifier;
     AsynchIO* aio;
@@ -54,7 +58,7 @@
     void activateOutput();
 
     // Input side
-    void readbuff(AsynchIO& aio, AsynchIO::BufferBase* buff);
+    void readbuff(AsynchIO& aio, AsynchIOBufferBase* buff);
     void eof(AsynchIO& aio);
     void disconnect(AsynchIO& aio);
 	

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h Wed Jul  9 13:36:17 2008
@@ -35,6 +35,8 @@
 class ProtocolFactory : public qpid::SharedObject<ProtocolFactory>
 {
   public:
+    typedef boost::function2<void, int, std::string> ConnectFailedCallback;
+
     virtual ~ProtocolFactory() = 0;
     virtual uint16_t getPort() const = 0;
     virtual std::string getHost() const = 0;
@@ -43,7 +45,7 @@
         boost::shared_ptr<Poller>,
         const std::string& host, int16_t port,
         ConnectionCodec::Factory* codec,
-        boost::function2<void, int, std::string> failed) = 0;
+        ConnectFailedCallback failed) = 0;
 };
 
 inline ProtocolFactory::~ProtocolFactory() {}

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp Wed Jul  9 13:36:17 2008
@@ -24,6 +24,7 @@
 #include "AsynchIO.h"
 
 #include "qpid/Plugin.h"
+#include "qpid/sys/Socket.h"
 #include "qpid/broker/Broker.h"
 #include "qpid/log/Statement.h"
 
@@ -112,7 +113,7 @@
     Poller::shared_ptr poller,
     const std::string& host, int16_t port,
     ConnectionCodec::Factory* fact,
-    boost::function2<void, int, std::string> failed)
+    ConnectFailedCallback failed)
 {
     // Note that the following logic does not cause a memory leak.
     // The allocated Socket is freed either by the AsynchConnector

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp?rev=675338&r1=675337&r2=675338&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp Wed Jul  9 13:36:17 2008
@@ -20,6 +20,7 @@
  */
 
 #include "qpid/sys/AsynchIO.h"
+#include "qpid/sys/Socket.h"
 #include "qpid/sys/Time.h"
 
 #include "check.h"