aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/WakeFD.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-06 23:25:57 +0200
committerMax Kellermann <max@duempel.org>2013-08-06 23:32:21 +0200
commit47e16dbee3d43a8fac8e2337df442814ec6d036b (patch)
tree011c45b1d151425adaef1168fcf6ba7238d6e82a /src/event/WakeFD.hxx
parent66f678023f6e18dde9679d0a69565d6a50d09ed4 (diff)
downloadmpd-47e16dbee3d43a8fac8e2337df442814ec6d036b.tar.gz
mpd-47e16dbee3d43a8fac8e2337df442814ec6d036b.tar.xz
mpd-47e16dbee3d43a8fac8e2337df442814ec6d036b.zip
configure.ac: add option --enable-eventfd
Remove the runtime check for eventfd(), hard-code the feature once it's been selected at compile time. The class WakeFD is splitted into EventFD and EventPipe, using WakeFD as a macro diversion.
Diffstat (limited to '')
-rw-r--r--src/event/WakeFD.hxx55
1 files changed, 5 insertions, 50 deletions
diff --git a/src/event/WakeFD.hxx b/src/event/WakeFD.hxx
index 15b66b4cf..e4058287f 100644
--- a/src/event/WakeFD.hxx
+++ b/src/event/WakeFD.hxx
@@ -24,57 +24,12 @@
#include <assert.h>
-/**
- * This class can be used to wake up an I/O event loop.
- *
- * For optimization purposes, this class does not have a constructor
- * or a destructor.
- */
-class WakeFD {
- int fds[2];
-
-public:
-#ifdef NDEBUG
- WakeFD() = default;
+#ifdef USE_EVENTFD
+#include "EventFD.hxx"
+#define WakeFD EventFD
#else
- WakeFD():fds{-1, -1} {};
-#endif
-
- WakeFD(const WakeFD &other) = delete;
- WakeFD &operator=(const WakeFD &other) = delete;
-
- bool Create();
- void Destroy();
-
- int Get() const {
- assert(fds[0] >= 0);
-#ifndef HAVE_EVENTFD
- assert(fds[1] >= 0);
-#endif
-
- return fds[0];
- }
-
- /**
- * Checks if Write() was called at least once since the last
- * Read() call.
- */
- bool Read();
-
- /**
- * Wakes up the reader. Multiple calls to this function will
- * be combined to one wakeup.
- */
- void Write();
-
-private:
-#ifdef HAVE_EVENTFD
- bool IsEventFD() {
- assert(fds[0] >= 0);
-
- return fds[1] == -2;
- }
+#include "EventPipe.hxx"
+#define WakeFD EventPipe
#endif
-};
#endif /* MAIN_NOTIFY_H */