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/sys/AsynchIOAcceptor.cpp | |
| 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/sys/AsynchIOAcceptor.cpp')
| -rw-r--r-- | cpp/src/qpid/sys/AsynchIOAcceptor.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/cpp/src/qpid/sys/AsynchIOAcceptor.cpp b/cpp/src/qpid/sys/AsynchIOAcceptor.cpp index 5c784912b3..43fbfdf7be 100644 --- a/cpp/src/qpid/sys/AsynchIOAcceptor.cpp +++ b/cpp/src/qpid/sys/AsynchIOAcceptor.cpp @@ -84,19 +84,20 @@ struct Buff : public AsynchIO::BufferBase { }; class AsynchIOHandler : public OutputControl { + std::string identifier; AsynchIO* aio; ConnectionCodec::Factory* factory; ConnectionCodec* codec; bool readError; - std::string identifier; bool isClient; void write(const framing::ProtocolInitiation&); public: - AsynchIOHandler() : + AsynchIOHandler(std::string id, ConnectionCodec::Factory* f) : + identifier(id), aio(0), - factory(0), + factory(f), codec(0), readError(false), isClient(false) @@ -110,11 +111,8 @@ class AsynchIOHandler : public OutputControl { void setClient() { isClient = true; } - void init(AsynchIO* a, ConnectionCodec::Factory* f) { + void init(AsynchIO* a) { aio = a; - factory = f; - identifier = aio->getSocket().getPeerAddress(); - } // Output side @@ -133,7 +131,7 @@ class AsynchIOHandler : public OutputControl { }; void AsynchIOAcceptor::accepted(Poller::shared_ptr poller, const Socket& s, ConnectionCodec::Factory* f) { - AsynchIOHandler* async = new AsynchIOHandler; + AsynchIOHandler* async = new AsynchIOHandler(s.getPeerAddress(), f); AsynchIO* aio = new AsynchIO(s, boost::bind(&AsynchIOHandler::readbuff, async, _1, _2), boost::bind(&AsynchIOHandler::eof, async, _1), @@ -141,7 +139,8 @@ void AsynchIOAcceptor::accepted(Poller::shared_ptr poller, const Socket& s, Conn boost::bind(&AsynchIOHandler::closedSocket, async, _1, _2), boost::bind(&AsynchIOHandler::nobuffs, async, _1), boost::bind(&AsynchIOHandler::idle, async, _1)); - async->init(aio, f); + async->init(aio); + // Give connection some buffers to use for (int i = 0; i < 4; i++) { aio->queueReadBuffer(new Buff); @@ -185,7 +184,7 @@ void AsynchIOAcceptor::connect( { Socket* socket = new Socket();//Should be deleted by handle when socket closes socket->connect(host, port); - AsynchIOHandler* async = new AsynchIOHandler; + AsynchIOHandler* async = new AsynchIOHandler(socket->getPeerAddress(), f); async->setClient(); AsynchIO* aio = new AsynchIO(*socket, boost::bind(&AsynchIOHandler::readbuff, async, _1, _2), @@ -194,7 +193,8 @@ void AsynchIOAcceptor::connect( boost::bind(&AsynchIOHandler::closedSocket, async, _1, _2), boost::bind(&AsynchIOHandler::nobuffs, async, _1), boost::bind(&AsynchIOHandler::idle, async, _1)); - async->init(aio, f); + async->init(aio); + // Give connection some buffers to use for (int i = 0; i < 4; i++) { aio->queueReadBuffer(new Buff); |
