event/WakeFD: convert macro to class with a GetSocket() method
This commit is contained in:
parent
0d606c743b
commit
cd4b673b6c
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user