Linux eventfd() implementation

x::eventfd is a reference to a reference-counted object that implements the Linux kernel eventfd(2) API.

x::eventfd ev(x::eventfd::create());

// ...

ev->event(1);

// ...
eventfd_t cnt=ev->event();

event(n) increments the event file descriptor's event counter by n (calling the eventfd_write() function, as documented in the eventfd(2) manual page. event() calls eventfd_read, and returns the event count.

The event file descriptor inherits from the file descriptor object. It is safe to use the following methods from the underlying file descriptor object: epoll() (allowing the file descriptor object to be used in an epoll set), closeonexec(), nonblock(), and get_fd(). Using other methods is discouraged, to avoid unintended side-effects.