aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/MultiSocketMonitor.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/event/MultiSocketMonitor.cxx44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/event/MultiSocketMonitor.cxx b/src/event/MultiSocketMonitor.cxx
index dcc5edb38..2ebad02e5 100644
--- a/src/event/MultiSocketMonitor.cxx
+++ b/src/event/MultiSocketMonitor.cxx
@@ -25,6 +25,48 @@
#include <assert.h>
+#ifdef USE_EPOLL
+
+MultiSocketMonitor::MultiSocketMonitor(EventLoop &_loop)
+ :IdleMonitor(_loop), TimeoutMonitor(_loop), ready(false) {
+}
+
+MultiSocketMonitor::~MultiSocketMonitor()
+{
+ // TODO
+}
+
+void
+MultiSocketMonitor::Prepare()
+{
+ int timeout_ms = PrepareSockets();
+ if (timeout_ms >= 0)
+ TimeoutMonitor::Schedule(timeout_ms);
+ else
+ TimeoutMonitor::Cancel();
+
+}
+
+void
+MultiSocketMonitor::OnIdle()
+{
+ if (ready) {
+ ready = false;
+ DispatchSockets();
+
+ /* TODO: don't refresh always; require users to call
+ InvalidateSockets() */
+ refresh = true;
+ }
+
+ if (refresh) {
+ refresh = false;
+ Prepare();
+ }
+}
+
+#else
+
/**
* The vtable for our GSource implementation. Unfortunately, we
* cannot declare it "const", because g_source_new() takes a non-const
@@ -117,3 +159,5 @@ MultiSocketMonitor::Dispatch(GSource *_source,
monitor.Dispatch();
return true;
}
+
+#endif