event/WakeFD: convert macro to class with a GetSocket() method

This commit is contained in:
Max Kellermann 2021-01-11 17:00:54 +01:00
parent 0d606c743b
commit cd4b673b6c
2 changed files with 23 additions and 3 deletions

View File

@ -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
}

View File

@ -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