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/epoll/EpollPoller.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/epoll/EpollPoller.cpp')
| -rw-r--r-- | cpp/src/qpid/sys/epoll/EpollPoller.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/cpp/src/qpid/sys/epoll/EpollPoller.cpp b/cpp/src/qpid/sys/epoll/EpollPoller.cpp index 8936251f94..44b84c4239 100644 --- a/cpp/src/qpid/sys/epoll/EpollPoller.cpp +++ b/cpp/src/qpid/sys/epoll/EpollPoller.cpp @@ -20,6 +20,7 @@ */ #include "qpid/sys/Poller.h" +#include "qpid/sys/IOHandle.h" #include "qpid/sys/Mutex.h" #include "qpid/sys/DeletionManager.h" #include "qpid/sys/posix/check.h" @@ -54,11 +55,13 @@ class PollerHandlePrivate { MONITORED_HUNGUP }; + int fd; ::__uint32_t events; FDStat stat; Mutex lock; - PollerHandlePrivate() : + PollerHandlePrivate(int f) : + fd(f), events(0), stat(ABSENT) { } @@ -97,9 +100,8 @@ class PollerHandlePrivate { } }; -PollerHandle::PollerHandle(const Socket& s) : - impl(new PollerHandlePrivate), - socket(s) +PollerHandle::PollerHandle(const IOHandle& h) : + impl(new PollerHandlePrivate(toFd(h.impl))) {} PollerHandle::~PollerHandle() { @@ -201,7 +203,7 @@ void Poller::addFd(PollerHandle& handle, Direction dir) { } epe.data.ptr = &handle; - QPID_POSIX_CHECK(::epoll_ctl(impl->epollFd, op, toFd(handle.socket.impl), &epe)); + QPID_POSIX_CHECK(::epoll_ctl(impl->epollFd, op, eh.fd, &epe)); // Record monitoring state of this fd eh.events = epe.events; @@ -212,7 +214,7 @@ void Poller::delFd(PollerHandle& handle) { PollerHandlePrivate& eh = *handle.impl; ScopedLock<Mutex> l(eh.lock); assert(!eh.isIdle()); - int rc = ::epoll_ctl(impl->epollFd, EPOLL_CTL_DEL, toFd(handle.socket.impl), 0); + int rc = ::epoll_ctl(impl->epollFd, EPOLL_CTL_DEL, eh.fd, 0); // Ignore EBADF since deleting a nonexistent fd has the overall required result! // And allows the case where a sloppy program closes the fd and then does the delFd() if (rc == -1 && errno != EBADF) { @@ -231,7 +233,7 @@ void Poller::modFd(PollerHandle& handle, Direction dir) { epe.events = PollerPrivate::directionToEpollEvent(dir) | ::EPOLLONESHOT; epe.data.ptr = &handle; - QPID_POSIX_CHECK(::epoll_ctl(impl->epollFd, EPOLL_CTL_MOD, toFd(handle.socket.impl), &epe)); + QPID_POSIX_CHECK(::epoll_ctl(impl->epollFd, EPOLL_CTL_MOD, eh.fd, &epe)); // Record monitoring state of this fd eh.events = epe.events; @@ -247,7 +249,7 @@ void Poller::rearmFd(PollerHandle& handle) { epe.events = eh.events; epe.data.ptr = &handle; - QPID_POSIX_CHECK(::epoll_ctl(impl->epollFd, EPOLL_CTL_MOD, toFd(handle.socket.impl), &epe)); + QPID_POSIX_CHECK(::epoll_ctl(impl->epollFd, EPOLL_CTL_MOD, eh.fd, &epe)); eh.setActive(); } |
