qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r826032 - in /qpid/trunk/qpid/cpp/src/qpid/sys: AsynchIO.h TCPIOPlugin.cpp posix/AsynchIO.cpp
Date Fri, 16 Oct 2009 18:47:47 GMT
Author: astitcher
Date: Fri Oct 16 18:47:47 2009
New Revision: 826032

URL: http://svn.apache.org/viewvc?rev=826032&view=rev
Log:
Rationalised AsynchConnector/Acceptor/IO to all use the same code structure

Modified:
    qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h
    qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h?rev=826032&r1=826031&r2=826032&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h Fri Oct 16 18:47:47 2009
@@ -36,18 +36,13 @@
  * Asynchronous acceptor: accepts connections then does a callback with the
  * accepted fd
  */
-class AsynchAcceptorPrivate;
 class AsynchAcceptor {
 public:
     typedef boost::function1<void, const Socket&> Callback;
 
-private:
-    AsynchAcceptorPrivate* impl;
-
-public:
-    QPID_COMMON_EXTERN AsynchAcceptor(const Socket& s, Callback callback);
-    QPID_COMMON_EXTERN ~AsynchAcceptor();
-    QPID_COMMON_EXTERN void start(boost::shared_ptr<Poller> poller);
+    QPID_COMMON_EXTERN static AsynchAcceptor* create(const Socket& s, Callback callback);
+    virtual ~AsynchAcceptor() {};
+    virtual void start(boost::shared_ptr<Poller> poller) = 0;
 };
 
 /*

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp?rev=826032&r1=826031&r2=826032&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp Fri Oct 16 18:47:47 2009
@@ -114,7 +114,7 @@
 void AsynchIOProtocolFactory::accept(Poller::shared_ptr poller,
                                      ConnectionCodec::Factory* fact) {
     acceptor.reset(
-        new AsynchAcceptor(listener,
+        AsynchAcceptor::create(listener,
                            boost::bind(&AsynchIOProtocolFactory::established, this, poller,
_1, fact, false)));
     acceptor->start(poller);
 }

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp?rev=826032&r1=826031&r2=826032&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp Fri Oct 16 18:47:47 2009
@@ -73,11 +73,12 @@
  */
 namespace qpid {
 namespace sys {
+namespace posix {
 
-class AsynchAcceptorPrivate {
+class AsynchAcceptor : public qpid::sys::AsynchAcceptor {
 public:
-    AsynchAcceptorPrivate(const Socket& s, AsynchAcceptor::Callback callback);
-    ~AsynchAcceptorPrivate();
+    AsynchAcceptor(const Socket& s, AsynchAcceptor::Callback callback);
+    ~AsynchAcceptor();
     void start(Poller::shared_ptr poller);
 
 private:
@@ -90,40 +91,27 @@
 
 };
 
-}} // namespace qpid::sys
-
-AsynchAcceptor::AsynchAcceptor(const Socket& s, Callback callback) :
-  impl(new AsynchAcceptorPrivate(s, callback))
-{}
-
-AsynchAcceptor::~AsynchAcceptor()
-{ delete impl;}
-
-void AsynchAcceptor::start(Poller::shared_ptr poller) {
-    impl->start(poller);
-}
-
-AsynchAcceptorPrivate::AsynchAcceptorPrivate(const Socket& s,
-                                             AsynchAcceptor::Callback callback) :
+AsynchAcceptor::AsynchAcceptor(const Socket& s,
+                               AsynchAcceptor::Callback callback) :
     acceptedCallback(callback),
-    handle(s, boost::bind(&AsynchAcceptorPrivate::readable, this, _1), 0, 0),
+    handle(s, boost::bind(&AsynchAcceptor::readable, this, _1), 0, 0),
     socket(s) {
 
     s.setNonblocking();
 }
 
-AsynchAcceptorPrivate::~AsynchAcceptorPrivate() {
+AsynchAcceptor::~AsynchAcceptor() {
     handle.stopWatch();
 }
 
-void AsynchAcceptorPrivate::start(Poller::shared_ptr poller) {
+void AsynchAcceptor::start(Poller::shared_ptr poller) {
     handle.startWatch(poller);
 }
 
 /*
  * We keep on accepting as long as there is something to accept
  */
-void AsynchAcceptorPrivate::readable(DispatchHandle& h) {
+void AsynchAcceptor::readable(DispatchHandle& h) {
     Socket* s;
     do {
         errno = 0;
@@ -146,13 +134,6 @@
 }
 
 /*
- * Asynch Connector
- */
-namespace qpid {
-namespace sys {
-namespace posix {
-
-/*
  * POSIX version of AsynchIO TCP socket connector.
  *
  * The class is implemented in terms of DispatchHandle to allow it to be
@@ -228,32 +209,12 @@
     DispatchHandle::doDelete();
 }
 
-} // namespace posix
-
-
-AsynchConnector* qpid::sys::AsynchConnector::create(const Socket& s,
-                                                    Poller::shared_ptr poller,
-                                                    std::string hostname,
-                                                    uint16_t port,
-                                                    ConnectedCallback connCb,
-                                                    FailedCallback failCb)
-{
-    return new qpid::sys::posix::AsynchConnector(s,
-                                                 poller,
-                                                 hostname,
-                                                 port,
-                                                 connCb,
-                                                 failCb);
-}
-
 /*
  * POSIX version of AsynchIO reader/writer
  *
  * The class is implemented in terms of DispatchHandle to allow it to be
  * deleted by deleting the contained DispatchHandle.
  */
-namespace posix {
-
 class AsynchIO : public qpid::sys::AsynchIO, private DispatchHandle {
 
 public:
@@ -629,15 +590,31 @@
 
 } // namespace posix
 
-AsynchIO* qpid::sys::AsynchIO::create(const Socket& s,
-                                      AsynchIO::ReadCallback rCb,
-                                      AsynchIO::EofCallback eofCb,
-                                      AsynchIO::DisconnectCallback disCb,
-                                      AsynchIO::ClosedCallback cCb,
-                                      AsynchIO::BuffersEmptyCallback eCb,
-                                      AsynchIO::IdleCallback iCb)
+AsynchAcceptor* AsynchAcceptor::create(const Socket& s, 
+                                       Callback callback)
+{
+    return new posix::AsynchAcceptor(s, callback);
+}
+
+AsynchConnector* AsynchConnector::create(const Socket& s,
+                                         Poller::shared_ptr poller,
+                                         std::string hostname,
+                                         uint16_t port,
+                                         ConnectedCallback connCb,
+                                         FailedCallback failCb)
+{
+    return new posix::AsynchConnector(s, poller, hostname, port, connCb, failCb);
+}
+
+AsynchIO* AsynchIO::create(const Socket& s,
+                           AsynchIO::ReadCallback rCb,
+                           AsynchIO::EofCallback eofCb,
+                           AsynchIO::DisconnectCallback disCb,
+                           AsynchIO::ClosedCallback cCb,
+                           AsynchIO::BuffersEmptyCallback eCb,
+                           AsynchIO::IdleCallback iCb)
 {
-    return new qpid::sys::posix::AsynchIO(s, rCb, eofCb, disCb, cCb, eCb, iCb);
+    return new posix::AsynchIO(s, rCb, eofCb, disCb, cCb, eCb, iCb);
 }
 
 }} // namespace qpid::sys



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message