mpd/src/system/EventFD.hxx

39 lines
622 B
C++
Raw Normal View History

// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>
#ifndef EVENT_FD_HXX
#define EVENT_FD_HXX
2020-05-05 14:11:13 +02:00
#include "io/UniqueFileDescriptor.hxx"
/**
* A class that wraps eventfd().
*/
class EventFD {
UniqueFileDescriptor fd;
public:
/**
* Throws on error.
*/
EventFD();
FileDescriptor Get() const noexcept {
return fd;
}
/**
* Checks if Write() was called at least once since the last
* Read() call.
*/
2018-08-06 11:57:40 +02:00
bool Read() noexcept;
/**
* Wakes up the reader. Multiple calls to this function will
* be combined to one wakeup.
*/
2018-08-06 11:57:40 +02:00
void Write() noexcept;
};
#endif