summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/Poller.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/sys/Poller.h')
-rw-r--r--cpp/src/qpid/sys/Poller.h52
1 files changed, 35 insertions, 17 deletions
diff --git a/cpp/src/qpid/sys/Poller.h b/cpp/src/qpid/sys/Poller.h
index e39528bdb5..413d4242b8 100644
--- a/cpp/src/qpid/sys/Poller.h
+++ b/cpp/src/qpid/sys/Poller.h
@@ -22,8 +22,9 @@
*
*/
-#include "Time.h"
-
+#include "qpid/sys/Time.h"
+#include "qpid/sys/Runnable.h"
+#include "qpid/CommonImportExport.h"
#include <boost/shared_ptr.hpp>
namespace qpid {
@@ -37,7 +38,7 @@ namespace sys {
*/
class PollerHandle;
class PollerPrivate;
-class Poller {
+class Poller : public Runnable {
PollerPrivate* const impl;
public:
@@ -45,8 +46,8 @@ public:
enum Direction {
NONE = 0,
- IN,
- OUT,
+ INPUT,
+ OUTPUT,
INOUT
};
@@ -57,7 +58,8 @@ public:
READ_WRITABLE,
DISCONNECTED,
SHUTDOWN,
- TIMEOUT
+ TIMEOUT,
+ INTERRUPTED
};
struct Event {
@@ -72,16 +74,31 @@ public:
void process();
};
- Poller();
- ~Poller();
+ QPID_COMMON_EXTERN Poller();
+ QPID_COMMON_EXTERN ~Poller();
/** Note: this function is async-signal safe */
- void shutdown();
+ QPID_COMMON_EXTERN void shutdown();
+
+ // Interrupt waiting for a specific poller handle
+ // returns true if we could interrupt the handle
+ // - in this case on return the handle is no longer being monitored,
+ // but we will receive an event from some invocation of poller::wait
+ // with the handle and the INTERRUPTED event type
+ // if it returns false then the handle is not being monitored by the poller
+ // - This can either be because it has just received an event which has been
+ // reported and has not been reenabled since.
+ // - Because it was removed from the monitoring set
+ // - Or because it is already being interrupted
+ QPID_COMMON_EXTERN bool interrupt(PollerHandle& handle);
+
+ // Poller run loop
+ QPID_COMMON_EXTERN void run();
- void addFd(PollerHandle& handle, Direction dir);
- void delFd(PollerHandle& handle);
- void modFd(PollerHandle& handle, Direction dir);
- void rearmFd(PollerHandle& handle);
- Event wait(Duration timeout = TIME_INFINITE);
+ QPID_COMMON_EXTERN void registerHandle(PollerHandle& handle);
+ QPID_COMMON_EXTERN void unregisterHandle(PollerHandle& handle);
+ QPID_COMMON_EXTERN void monitorHandle(PollerHandle& handle, Direction dir);
+ QPID_COMMON_EXTERN void unmonitorHandle(PollerHandle& handle, Direction dir);
+ QPID_COMMON_EXTERN Event wait(Duration timeout = TIME_INFINITE);
};
/**
@@ -91,14 +108,15 @@ class IOHandle;
class PollerHandlePrivate;
class PollerHandle {
friend class Poller;
+ friend class PollerPrivate;
friend struct Poller::Event;
PollerHandlePrivate* const impl;
- virtual void processEvent(Poller::EventType) {};
+ QPID_COMMON_EXTERN virtual void processEvent(Poller::EventType) {};
public:
- PollerHandle(const IOHandle& h);
- virtual ~PollerHandle();
+ QPID_COMMON_EXTERN PollerHandle(const IOHandle& h);
+ QPID_COMMON_EXTERN virtual ~PollerHandle();
};
inline void Poller::Event::process() {