diff options
Diffstat (limited to 'src/event/TimeoutMonitor.hxx')
-rw-r--r-- | src/event/TimeoutMonitor.hxx | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/event/TimeoutMonitor.hxx b/src/event/TimeoutMonitor.hxx index 98e4e5564..568aa27ef 100644 --- a/src/event/TimeoutMonitor.hxx +++ b/src/event/TimeoutMonitor.hxx @@ -22,31 +22,39 @@ #include "check.h" -#ifndef USE_EPOLL +#ifdef USE_GLIB_EVENTLOOP #include <glib.h> #endif class EventLoop; +/** + * This class monitors a timeout. Use Schedule() to begin the timeout + * or Cancel() to cancel it. + */ class TimeoutMonitor { -#ifdef USE_EPOLL +#ifdef USE_INTERNAL_EVENTLOOP friend class EventLoop; #endif EventLoop &loop; -#ifdef USE_EPOLL +#ifdef USE_INTERNAL_EVENTLOOP bool active; -#else +#endif + +#ifdef USE_GLIB_EVENTLOOP GSource *source; #endif public: -#ifdef USE_EPOLL +#ifdef USE_INTERNAL_EVENTLOOP TimeoutMonitor(EventLoop &_loop) :loop(_loop), active(false) { } -#else +#endif + +#ifdef USE_GLIB_EVENTLOOP TimeoutMonitor(EventLoop &_loop) :loop(_loop), source(nullptr) {} #endif @@ -60,9 +68,11 @@ public: } bool IsActive() const { -#ifdef USE_EPOLL +#ifdef USE_INTERNAL_EVENTLOOP return active; -#else +#endif + +#ifdef USE_GLIB_EVENTLOOP return source != nullptr; #endif } @@ -77,7 +87,7 @@ protected: private: void Run(); -#ifndef USE_EPOLL +#ifdef USE_GLIB_EVENTLOOP static gboolean Callback(gpointer data); #endif }; |