aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/IdleMonitor.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-07 22:16:59 +0200
committerMax Kellermann <max@duempel.org>2013-08-10 13:54:23 +0200
commitc1f4f1fdb64d97b5c3461723a8482ca64efea30e (patch)
tree54c8a9c1466beec0dbfac1c0b5f5773060c1aa2b /src/event/IdleMonitor.hxx
parent342333f72a484e9f394026666c4b20e54dc9b756 (diff)
downloadmpd-c1f4f1fdb64d97b5c3461723a8482ca64efea30e.tar.gz
mpd-c1f4f1fdb64d97b5c3461723a8482ca64efea30e.tar.xz
mpd-c1f4f1fdb64d97b5c3461723a8482ca64efea30e.zip
EventLoop: new implementation using epoll
Implement an event loop without GLib.
Diffstat (limited to 'src/event/IdleMonitor.hxx')
-rw-r--r--src/event/IdleMonitor.hxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/event/IdleMonitor.hxx b/src/event/IdleMonitor.hxx
index ee9f5e392..c8e79eb1d 100644
--- a/src/event/IdleMonitor.hxx
+++ b/src/event/IdleMonitor.hxx
@@ -22,7 +22,9 @@
#include "check.h"
+#ifndef USE_EPOLL
#include <glib.h>
+#endif
class EventLoop;
@@ -32,13 +34,26 @@ class EventLoop;
* methods must be run from EventLoop's thread.
*/
class IdleMonitor {
+#ifdef USE_EPOLL
+ friend class EventLoop;
+#endif
+
EventLoop &loop;
+#ifdef USE_EPOLL
+ bool active;
+#else
guint source_id;
+#endif
public:
+#ifdef USE_EPOLL
+ IdleMonitor(EventLoop &_loop)
+ :loop(_loop), active(false) {}
+#else
IdleMonitor(EventLoop &_loop)
:loop(_loop), source_id(0) {}
+#endif
~IdleMonitor() {
Cancel();
@@ -49,7 +64,11 @@ public:
}
bool IsActive() const {
+#ifdef USE_EPOLL
+ return active;
+#else
return source_id != 0;
+#endif
}
void Schedule();
@@ -60,7 +79,9 @@ protected:
private:
void Run();
+#ifndef USE_EPOLL
static gboolean Callback(gpointer data);
+#endif
};
#endif /* MAIN_NOTIFY_H */