From cd4b673b6c2868e2855c9f4c9be20c88230a93a3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 11 Jan 2021 17:00:54 +0100 Subject: [PATCH] event/WakeFD: convert macro to class with a GetSocket() method --- src/event/Loop.cxx | 2 +- src/event/WakeFD.hxx | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx index 65d890823..23408784c 100644 --- a/src/event/Loop.cxx +++ b/src/event/Loop.cxx @@ -57,7 +57,7 @@ EventLoop::EventLoop( #endif { #ifdef HAVE_THREADED_EVENT_LOOP - wake_event.Open(SocketDescriptor(wake_fd.Get())); + wake_event.Open(wake_fd.GetSocket()); #endif } diff --git a/src/event/WakeFD.hxx b/src/event/WakeFD.hxx index 957238699..e26bcaee2 100644 --- a/src/event/WakeFD.hxx +++ b/src/event/WakeFD.hxx @@ -20,14 +20,34 @@ #ifndef MPD_WAKE_FD_HXX #define MPD_WAKE_FD_HXX +#include "net/SocketDescriptor.hxx" #include "event/Features.h" #ifdef USE_EVENTFD #include "system/EventFD.hxx" -#define WakeFD EventFD #else #include "system/EventPipe.hxx" -#define WakeFD EventPipe #endif +class WakeFD { +#ifdef USE_EVENTFD + EventFD fd; +#else + EventPipe fd; +#endif + +public: + SocketDescriptor GetSocket() const noexcept { + return SocketDescriptor(fd.Get()); + } + + bool Read() noexcept { + return fd.Read(); + } + + void Write() noexcept { + fd.Write(); + } +}; + #endif