diff options
author | Max Kellermann <max@duempel.org> | 2013-08-07 22:16:59 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-10 13:54:23 +0200 |
commit | c1f4f1fdb64d97b5c3461723a8482ca64efea30e (patch) | |
tree | 54c8a9c1466beec0dbfac1c0b5f5773060c1aa2b /src/event/TimeoutMonitor.hxx | |
parent | 342333f72a484e9f394026666c4b20e54dc9b756 (diff) | |
download | mpd-c1f4f1fdb64d97b5c3461723a8482ca64efea30e.tar.gz mpd-c1f4f1fdb64d97b5c3461723a8482ca64efea30e.tar.xz mpd-c1f4f1fdb64d97b5c3461723a8482ca64efea30e.zip |
EventLoop: new implementation using epoll
Implement an event loop without GLib.
Diffstat (limited to '')
-rw-r--r-- | src/event/TimeoutMonitor.hxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/event/TimeoutMonitor.hxx b/src/event/TimeoutMonitor.hxx index b0550933e..98e4e5564 100644 --- a/src/event/TimeoutMonitor.hxx +++ b/src/event/TimeoutMonitor.hxx @@ -22,17 +22,34 @@ #include "check.h" +#ifndef USE_EPOLL #include <glib.h> +#endif class EventLoop; class TimeoutMonitor { +#ifdef USE_EPOLL + friend class EventLoop; +#endif + EventLoop &loop; + +#ifdef USE_EPOLL + bool active; +#else GSource *source; +#endif public: +#ifdef USE_EPOLL + TimeoutMonitor(EventLoop &_loop) + :loop(_loop), active(false) { + } +#else TimeoutMonitor(EventLoop &_loop) :loop(_loop), source(nullptr) {} +#endif ~TimeoutMonitor() { Cancel(); @@ -43,7 +60,11 @@ public: } bool IsActive() const { +#ifdef USE_EPOLL + return active; +#else return source != nullptr; +#endif } void Schedule(unsigned ms); @@ -55,7 +76,10 @@ protected: private: void Run(); + +#ifndef USE_EPOLL static gboolean Callback(gpointer data); +#endif }; #endif /* MAIN_NOTIFY_H */ |