1SD-EVENT(3) sd-event SD-EVENT(3)
2
3
4
6 sd-event - A generic event loop implementation
7
9 #include <systemd/sd-event.h>
10
11 pkg-config --cflags --libs libsystemd
12
14 sd-event.h provides a generic event loop implementation, based on Linux
15 epoll(7).
16
17 See sd_event_new(3), sd_event_run(3), sd_event_add_io(3),
18 sd_event_add_time(3), sd_event_add_signal(3), sd_event_add_child(3),
19 sd_event_add_inotify(3), sd_event_add_defer(3),
20 sd_event_source_unref(3), sd_event_source_set_priority(3),
21 sd_event_source_set_enabled(3), sd_event_source_set_userdata(3),
22 sd_event_source_get_event(3), sd_event_source_get_pending(3),
23 sd_event_source_set_description(3), sd_event_source_set_prepare(3),
24 sd_event_source_set_ratelimit(3), sd_event_wait(3), sd_event_get_fd(3),
25 sd_event_set_watchdog(3), sd_event_exit(3), sd_event_now(3) for more
26 information about the functions available.
27
28 The event loop design is targeted on running a separate instance of the
29 event loop in each thread; it has no concept of distributing events
30 from a single event loop instance onto multiple worker threads.
31 Dispatching events is strictly ordered and subject to configurable
32 priorities. In each event loop iteration a single event source is
33 dispatched. Each time an event source is dispatched the kernel is
34 polled for new events, before the next event source is dispatched. The
35 event loop is designed to honor priorities and provide fairness within
36 each priority. It is not designed to provide optimal throughput, as
37 this contradicts these goals due the limitations of the underlying
38 epoll(7) primitives.
39
40 The event loop implementation provides the following features:
41
42 1. I/O event sources, based on epoll(7)'s file descriptor watching,
43 including edge triggered events (EPOLLET). See sd_event_add_io(3).
44
45 2. Timer event sources, based on timerfd_create(2), supporting the
46 CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_BOOTIME clocks, as well as
47 the CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM clocks that can
48 resume the system from suspend. When creating timer events a
49 required accuracy parameter may be specified which allows
50 coalescing of timer events to minimize power consumption. See
51 sd_event_add_time(3).
52
53 3. UNIX process signal events, based on signalfd(2), including full
54 support for real-time signals, and queued parameters. See
55 sd_event_add_signal(3).
56
57 4. Child process state change events, based on waitid(2). See
58 sd_event_add_child(3).
59
60 5. Static event sources, of three types: defer, post and exit, for
61 invoking calls in each event loop, after other event sources or at
62 event loop termination. See sd_event_add_defer(3).
63
64 6. Event sources may be assigned a 64bit priority value, that controls
65 the order in which event sources are dispatched if multiple are
66 pending simultaneously. See sd_event_source_set_priority(3).
67
68 7. The event loop may automatically send watchdog notification
69 messages to the service manager. See sd_event_set_watchdog(3).
70
71 8. The event loop may be integrated into foreign event loops, such as
72 the GLib one. See sd_event_get_fd(3) for an example.
73
75 These APIs are implemented as a shared library, which can be compiled
76 and linked to with the libsystemd pkg-config(1) file.
77
79 systemd(1), sd_event_new(3), sd_event_run(3), sd_event_add_io(3),
80 sd_event_add_time(3), sd_event_add_signal(3), sd_event_add_child(3),
81 sd_event_add_inotify(3), sd_event_add_defer(3),
82 sd_event_source_unref(3), sd_event_source_set_priority(3),
83 sd_event_source_set_enabled(3), sd_event_source_set_userdata(3),
84 sd_event_source_get_event(3), sd_event_source_get_pending(3),
85 sd_event_source_set_description(3), sd_event_source_set_prepare(3),
86 sd_event_source_set_ratelimit(3), sd_event_wait(3), sd_event_get_fd(3),
87 sd_event_set_watchdog(3), sd_event_exit(3), sd_event_now(3), epoll(7),
88 timerfd_create(2), signalfd(2), waitid(2)
89
90
91
92systemd 251 SD-EVENT(3)