sd-event
systemd
Developer
Lennart
Poettering
lennart@poettering.net
sd-event
3
sd-event
A generic event loop implementation
#include <systemd/sd-event.h>
pkg-config --cflags --libs libsystemd
Description
sd-event.h provides a generic event
loop implementation, based on Linux epoll7.
See
sd_event_new3,
sd_event_run3,
sd_event_add_io3,
sd_event_add_time3,
sd_event_add_signal3,
sd_event_add_child3,
sd_event_add_defer3,
sd_event_source_unref3,
sd_event_source_set_priority3,
sd_event_source_set_enabled3,
sd_event_source_set_userdata3,
sd_event_source_get_event3,
sd_event_source_get_pending3,
sd_event_source_set_description3,
sd_event_source_set_prepare3,
sd_event_wait3,
sd_event_get_fd3,
sd_event_set_watchdog3,
sd_event_exit3,
sd_event_now3
for more information about the functions available.
The event loop design is targeted on running a separate
instance of the event loop in each thread; it has no concept of
distributing events from a single event loop instance onto
multiple worker threads. Dispatching events is strictly ordered
and subject to configurable priorities. In each event loop
iteration a single event source is dispatched. Each time an event
source is dispatched the kernel is polled for new events, before
the next event source is dispatched. The event loop is designed to
honour priorities and provide fairness within each priority. It is
not designed to provide optimal throughput, as this contradicts
these goals due the limitations of the underlying epoll7
primitives.
The event loop implementation provides the following features:
I/O event sources, based on epoll7's
file descriptor watching, including edge triggered events (EPOLLET). See sd_event_add_io3.
Timer event sources, based on timerfd_create2,
supporting the CLOCK_MONOTONIC,
CLOCK_REALTIME,
CLOCK_BOOTIME clocks, as well as the
CLOCK_REALTIME_ALARM and
CLOCK_BOOTTIME_ALARM clocks that can resume
the system from suspend. When creating timer events a required
accuracy parameter may be specified which allows coalescing of
timer events to minimize power consumption. See sd_event_add_time3.
UNIX process signal events, based on
signalfd2,
including full support for real-time signals, and queued parameters. See sd_event_add_signal3.
Child process state change events, based on
waitid2. See sd_event_add_child3.
Static event sources, of three types: defer,
post and exit, for invoking calls in each event loop, after
other event sources or at event loop termination. See
sd_event_add_defer3.
Event sources may be assigned a 64bit priority
value, that controls the order in which event sources are
dispatched if multiple are pending simultaneously. See
sd_event_source_set_priority3.
The event loop may automatically send watchdog
notification messages to the service manager. See
sd_event_set_watchdog3.
The event loop may be integrated into foreign
event loops, such as the GLib one. See
sd_event_get_fd3
for an example.
See Also
systemd1,
sd_event_new3,
sd_event_run3,
sd_event_add_io3,
sd_event_add_time3,
sd_event_add_signal3,
sd_event_add_child3,
sd_event_add_defer3,
sd_event_source_unref3,
sd_event_source_set_priority3,
sd_event_source_set_enabled3,
sd_event_source_set_userdata3,
sd_event_source_get_event3,
sd_event_source_get_pending3,
sd_event_source_set_description3,
sd_event_source_set_prepare3,
sd_event_wait3,
sd_event_get_fd3,
sd_event_set_watchdog3,
sd_event_exit3,
sd_event_now3,
epoll7,
timerfd_create2,
signalfd2,
waitid2