diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2008-04-15 15:41:21 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2008-04-15 15:41:21 +0000 |
| commit | dd53b33c3badd538d2d25a35146d9ab032573cc0 (patch) | |
| tree | 305a9f3e6cdc5d88d6c78638c75dda9d3ddb9831 /cpp/src/qpid/client | |
| parent | 8ac8e19e4805e78c3adcab66f1aab2ef5190f48e (diff) | |
| download | qpid-python-dd53b33c3badd538d2d25a35146d9ab032573cc0.tar.gz | |
Refactored the IO framework that sits on top of Poller so that it uses a generalised IOHandle.
This means that you can define new classes derived from IOHandle (other than Socket) that
can also be added to a Poller and waited for.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@648288 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client')
| -rw-r--r-- | cpp/src/qpid/client/Connector.cpp | 15 | ||||
| -rw-r--r-- | cpp/src/qpid/client/Connector.h | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/cpp/src/qpid/client/Connector.cpp b/cpp/src/qpid/client/Connector.cpp index a0be05fbbc..11aff6184b 100644 --- a/cpp/src/qpid/client/Connector.cpp +++ b/cpp/src/qpid/client/Connector.cpp @@ -18,16 +18,17 @@ * under the License. * */ -#include <iostream> +#include "Connector.h" + #include "qpid/log/Statement.h" #include "qpid/sys/Time.h" #include "qpid/framing/AMQFrame.h" -#include "Connector.h" - #include "qpid/sys/AsynchIO.h" #include "qpid/sys/Dispatcher.h" #include "qpid/sys/Poller.h" #include "qpid/Msg.h" + +#include <iostream> #include <boost/bind.hpp> #include <boost/format.hpp> @@ -62,7 +63,7 @@ void Connector::connect(const std::string& host, int port){ Mutex::ScopedLock l(closedLock); assert(closed); socket.connect(host, port); - identifier=str(format("[%1% %2%]") % socket.getLocalPort() % socket.getPeerAddress()); + identifier = str(format("[%1% %2%]") % socket.getLocalPort() % socket.getPeerAddress()); closed = false; poller = Poller::shared_ptr(new Poller); aio = new AsynchIO(socket, @@ -72,7 +73,7 @@ void Connector::connect(const std::string& host, int port){ 0, // closed 0, // nobuffs boost::bind(&Connector::writebuff, this, _1)); - writer.setAio(aio); + writer.init(identifier, aio); } void Connector::init(){ @@ -184,11 +185,11 @@ Connector::Writer::Writer() : aio(0), buffer(0), lastEof(0) Connector::Writer::~Writer() { delete buffer; } -void Connector::Writer::setAio(sys::AsynchIO* a) { +void Connector::Writer::init(std::string id, sys::AsynchIO* a) { Mutex::ScopedLock l(lock); + identifier = id; aio = a; newBuffer(l); - identifier = str(format("[%1% %2%]") % aio->getSocket().getLocalPort() % aio->getSocket().getPeerAddress()); } void Connector::Writer::handle(framing::AMQFrame& frame) { diff --git a/cpp/src/qpid/client/Connector.h b/cpp/src/qpid/client/Connector.h index ffddbfd1be..78aad0b60a 100644 --- a/cpp/src/qpid/client/Connector.h +++ b/cpp/src/qpid/client/Connector.h @@ -68,7 +68,7 @@ class Connector : public framing::OutputHandler, Writer(); ~Writer(); - void setAio(sys::AsynchIO*); + void init(std::string id, sys::AsynchIO*); void handle(framing::AMQFrame&); void write(sys::AsynchIO&); }; |
