Events object

The event object provides a set of methods to handle event-driven sockets in the stack. When Duda I/O is started, it creates a fixed number of worker threads where each one is capable to receive a high number of incoming client connections, each thread have a separated main event loop based in the Linux epoll(7) interface.

The methods presented here, allows to register your own file descriptors or sockets into the main event loop for the active worker in question. Once the file descriptor is registered, you are responsible for it deletion. You can define different callbacks for the event desired, when handling events and callbacks, the following modes are available:

DUDA_EVENT_READ: some data is available for a read operation on the socket.

DUDA_EVENT_WRITE: the socket is ready for write operations.

DUDA_EVENT_RW: the socket is ready for read or write operations.

DUDA_EVENT_SLEEP: the socket events are disable, socket in sleep mode.

DUDA_EVENT_WAKEUP: wake up a sleeping socket.

Besides the callbacks and handlers, this interface also support notifications. When a worker is created, Duda also creates a notification interface for that main loop event, internally this is done through the Linux pipe(2) system call. So if you create your own threads and wants to send some notification to the default workers, you can issue it using the method event->signal(). The signaling system only allow to distribute unsigned 64 bits values (uint64_t).