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/posix/AsynchIO.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/posix/AsynchIO.cpp')
| -rw-r--r-- | cpp/src/qpid/sys/posix/AsynchIO.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/cpp/src/qpid/sys/posix/AsynchIO.cpp b/cpp/src/qpid/sys/posix/AsynchIO.cpp index 94c68bd5d0..cedad5c011 100644 --- a/cpp/src/qpid/sys/posix/AsynchIO.cpp +++ b/cpp/src/qpid/sys/posix/AsynchIO.cpp @@ -65,7 +65,8 @@ __thread int64_t threadMaxReadTimeNs = 2 * 1000000; // start at 2ms AsynchAcceptor::AsynchAcceptor(const Socket& s, Callback callback) : acceptedCallback(callback), - handle(s, boost::bind(&AsynchAcceptor::readable, this, _1), 0, 0) { + handle(s, boost::bind(&AsynchAcceptor::readable, this, _1), 0, 0), + socket(s) { s.setNonblocking(); ignoreSigpipe(); @@ -84,7 +85,7 @@ void AsynchAcceptor::readable(DispatchHandle& h) { errno = 0; // TODO: Currently we ignore the peers address, perhaps we should // log it or use it for connection acceptance. - s = h.getSocket().accept(0, 0); + s = socket.accept(0, 0); if (s) { acceptedCallback(*s); } else { @@ -112,6 +113,7 @@ AsynchIO::AsynchIO(const Socket& s, closedCallback(cCb), emptyCallback(eCb), idleCallback(iCb), + socket(s), queuedClose(false), writePending(false) { @@ -209,7 +211,7 @@ void AsynchIO::readable(DispatchHandle& h) { bufferQueue.pop_front(); errno = 0; int readCount = buff->byteCount-buff->dataCount; - int rc = h.getSocket().read(buff->bytes + buff->dataCount, readCount); + int rc = socket.read(buff->bytes + buff->dataCount, readCount); if (rc > 0) { buff->dataCount += rc; threadReadTotal += rc; @@ -276,7 +278,7 @@ void AsynchIO::writeable(DispatchHandle& h) { writeQueue.pop_back(); errno = 0; assert(buff->dataStart+buff->dataCount <= buff->byteCount); - int rc = h.getSocket().write(buff->bytes+buff->dataStart, buff->dataCount); + int rc = socket.write(buff->bytes+buff->dataStart, buff->dataCount); if (rc >= 0) { threadWriteTotal += rc; writeTotal += rc; @@ -356,9 +358,9 @@ void AsynchIO::disconnected(DispatchHandle& h) { */ void AsynchIO::close(DispatchHandle& h) { h.stopWatch(); - h.getSocket().close(); + socket.close(); if (closedCallback) { - closedCallback(*this, getSocket()); + closedCallback(*this, socket); } } |
