1SD_EVENT_SOURCE_SET_PRIORIsTdY_(e3v)ent_source_set_priSoDr_iEtVyENT_SOURCE_SET_PRIORITY(3)
2
3
4
6 sd_event_source_set_priority, sd_event_source_get_priority,
7 SD_EVENT_PRIORITY_IMPORTANT, SD_EVENT_PRIORITY_NORMAL,
8 SD_EVENT_PRIORITY_IDLE - Set or retrieve the priority of event sources
9
11 #include <systemd/sd-event.h>
12
13 enum {
14 SD_EVENT_PRIORITY_IMPORTANT = -100,
15 SD_EVENT_PRIORITY_NORMAL = 0,
16 SD_EVENT_PRIORITY_IDLE = 100,
17 };
18
19 int sd_event_source_set_priority(sd_event_source *source,
20 int64_t priority);
21
22 int sd_event_source_get_priority(sd_event_source *source,
23 int64_t *priority);
24
26 sd_event_source_set_priority() may be used to set the priority for the
27 event source object specified as source. The priority is specified as
28 an arbitrary signed 64bit integer. The priority is initialized to
29 SD_EVENT_PRIORITY_NORMAL (0) when the event source is allocated with a
30 call such as sd_event_add_io(3) or sd_event_add_time(3), and may be
31 changed with this call. If multiple event sources have seen events at
32 the same time, they are dispatched in the order indicated by the event
33 sources' priorities. Event sources with smaller priority values are
34 dispatched first. As well-known points of reference, the constants
35 SD_EVENT_PRIORITY_IMPORTANT (-100), SD_EVENT_PRIORITY_NORMAL (0) and
36 SD_EVENT_PRIORITY_IDLE (100) may be used to indicate event sources that
37 shall be dispatched early, normally or late. It is recommended to
38 specify priorities based on these definitions, and relative to them —
39 however, the full 64bit signed integer range is available for ordering
40 event sources.
41
42 Priorities define the order in which event sources that have seen
43 events are dispatched. Care should be taken to ensure that
44 high-priority event sources (those with negative priority values
45 assigned) do not cause starvation of low-priority event sources (those
46 with positive priority values assigned).
47
48 The order in which event sources with the same priority are dispatched
49 is undefined, but the event loop generally tries to dispatch them in
50 the order it learnt about events on them. As the backing kernel
51 primitives do not provide accurate information about the order in which
52 events occurred this is not necessarily reliable. However, it is
53 guaranteed that if events are seen on multiple same-priority event
54 sources at the same time, each one is not dispatched again until all
55 others have been dispatched once. This behavior guarantees that within
56 each priority particular event sources do not starve or dominate the
57 event loop.
58
59 The priority of event sources may be changed at any time of their
60 lifetime, with the exception of inotify event sources (i.e. those
61 created with sd_event_add_inotify(3)) whose priority may only be
62 changed in the time between their initial creation and the first
63 subsequent event loop iteration.
64
65 sd_event_source_get_priority() may be used to query the current
66 priority assigned to the event source object source.
67
69 On success, sd_event_source_set_priority() and
70 sd_event_source_get_priority() return a non-negative integer. On
71 failure, they return a negative errno-style error code.
72
73 Errors
74 Returned errors may indicate the following problems:
75
76 -EINVAL
77 source is not a valid pointer to an sd_event_source object.
78
79 -ENOMEM
80 Not enough memory.
81
82 -ESTALE
83 The event loop is already terminated.
84
85 -ECHILD
86 The event loop has been created in a different process.
87
89 These APIs are implemented as a shared library, which can be compiled
90 and linked to with the libsystemd pkg-config(1) file.
91
93 sd-event(3), sd_event_add_io(3), sd_event_add_time(3),
94 sd_event_add_signal(3), sd_event_add_child(3), sd_event_add_inotify(3),
95 sd_event_add_defer(3)
96
97
98
99systemd 243 SD_EVENT_SOURCE_SET_PRIORITY(3)