32 #include <sys/eventfd.h>
33 #include <system_error>
43 using namespace scc::util;
79 m_fd = ::eventfd(0, m);
85 if (::eventfd_read(m_fd, &val) == -1)
88 st <<
"eventfd_read()";
89 throw std::system_error(errno, std::system_category(), st.str());
96 if (::eventfd_write(m_fd, v) == -1)
99 st <<
"eventfd_write()";
100 throw std::system_error(errno, std::system_category(), st.str());
uint64_t read()
Read from (decrement) the event counter.
void reset(int=-1)
Reset the event.
Event(int=0)
Construct an event.
void write(uint64_t)
Write to (increment) the event counter.
@ semaphore
Semaphore mode. Event reads decrement the counter by 1. Otherwise, reads set the counter to 0.
@ nonblocking
Non-blocking mode. If an event is read while unsignalled, throws and exception.
Signaling kernel event counter.
int safe_close(int fd)
Signal safe close.
Signal-safe C library wrapper.