diff -r 27684460629f -r 720893ec7d48 src/server/daemon/event_linux.h --- a/src/server/daemon/event_linux.h Mon Aug 12 21:20:17 2024 +0200 +++ b/src/server/daemon/event_linux.h Tue Aug 13 19:59:42 2024 +0200 @@ -32,10 +32,16 @@ #include "event.h" #include +#include + #ifdef __cplusplus extern "C" { #endif +#define EV_QUEUE_RESERVE 8 + +typedef struct EventQueue EventQueue; + typedef struct EventHandlerLinux { /* * base eventhandler elements (fnreturn, watchlist) @@ -46,16 +52,58 @@ * epoll fd */ int ep; + /* - * pipe read fd + * eventfd for notifying that new elements + * in the event_queue are available */ - int eventin; + int event_fd; + + /* + * queue for custom events (event_send) + * each block can contain up to EV_MAX_EVENTS events + * the event loop should not retrieve more than one block + * + * first queue block + */ + EventQueue *queue_begin; + + /* + * last queue block + */ + EventQueue *queue_end; + /* - * pipe write fd + * allocated unused blocks + */ + EventQueue *reserve_block[EV_QUEUE_RESERVE]; + + /* + * number of unused blocks + */ + size_t num_reserve; + + /* + * mutex for event_queue */ - int eventout; + pthread_mutex_t queue_lock; } EventHandlerLinux; +struct EventQueue { + /* + * array of events + */ + Event *events[EV_MAX_EVENTS]; + /* + * number of events + */ + size_t numevents; + /* + * next event block + */ + EventQueue *next; +}; + void ev_handle_events(EventHandlerLinux *ev); int ev_convert2sys_events(int events);