Debian Codegraph @

upstream/debian-unstable/man3/sd_event_source_set_priority.3

raw
1 '\" t
2 .TH "SD_EVENT_SOURCE_SET_PRIORITY" "3" "" "systemd 261~rc3" "sd_event_source_set_priority"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 sd_event_source_set_priority, sd_event_source_get_priority, SD_EVENT_PRIORITY_IMPORTANT, SD_EVENT_PRIORITY_NORMAL, SD_EVENT_PRIORITY_IDLE \- Set or retrieve the priority of event sources
24 .SH "SYNOPSIS"
25 .sp
26 .ft B
27 .nf
28 #include <systemd/sd\-event\&.h>
29 .fi
30 .ft
31 .sp
32 .ft B
33 .nf
34 enum {
35 \fBSD_EVENT_PRIORITY_IMPORTANT\fR = \-100,
36 \fBSD_EVENT_PRIORITY_NORMAL\fR = 0,
37 \fBSD_EVENT_PRIORITY_IDLE\fR = 100,
38 };
39 .fi
40 .ft
41 .HP \w'int\ sd_event_source_set_priority('u
42 .BI "int sd_event_source_set_priority(sd_event_source\ *" "source" ", int64_t\ " "priority" ");"
43 .HP \w'int\ sd_event_source_get_priority('u
44 .BI "int sd_event_source_get_priority(sd_event_source\ *" "source" ", int64_t\ *" "priority" ");"
45 .SH "DESCRIPTION"
46 .PP
47 \fBsd_event_source_set_priority()\fR
48 may be used to set the priority for the event source object specified as
49 \fIsource\fR\&. The priority is specified as an arbitrary signed 64\-bit integer\&. The priority is initialized to
50 \fBSD_EVENT_PRIORITY_NORMAL\fR
51 (0) when the event source is allocated with a call such as
52 \fBsd_event_add_io\fR(3)
53 or
54 \fBsd_event_add_time\fR(3), and may be changed with this call\&. If multiple event sources have seen events at the same time, they are dispatched in the order indicated by the event sources\*(Aq priorities\&. Event sources with smaller priority values are dispatched first\&. As well\-known points of reference, the constants
55 \fBSD_EVENT_PRIORITY_IMPORTANT\fR
56 (\-100),
57 \fBSD_EVENT_PRIORITY_NORMAL\fR
58 (0) and
59 \fBSD_EVENT_PRIORITY_IDLE\fR
60 (100) may be used to indicate event sources that shall be dispatched early, normally or late\&. It is recommended to specify priorities based on these definitions, and relative to them \(em however, the full 64\-bit signed integer range is available for ordering event sources\&.
61 .PP
62 Priorities define the order in which event sources that have seen events are dispatched\&. Care should be taken to ensure that high\-priority event sources (those with negative priority values assigned) do not cause starvation of low\-priority event sources (those with positive priority values assigned)\&.
63 .PP
64 The order in which event sources with the same priority are dispatched is undefined, but the event loop generally tries to dispatch them in the order it learnt about events on them\&. As the backing kernel primitives do not provide accurate information about the order in which events occurred this is not necessarily reliable\&. However, it is guaranteed that if events are seen on multiple same\-priority event sources at the same time, each one is not dispatched again until all others have been dispatched once\&. This behavior guarantees that within each priority particular event sources do not starve or dominate the event loop\&.
65 .PP
66 The priority of event sources may be changed at any time of their lifetime, with the exception of inotify event sources (i\&.e\&. those created with
67 \fBsd_event_add_inotify\fR(3)) whose priority may only be changed in the time between their initial creation and the first subsequent event loop iteration\&.
68 .PP
69 \fBsd_event_source_get_priority()\fR
70 may be used to query the current priority assigned to the event source object
71 \fIsource\fR\&.
72 .SH "RETURN VALUE"
73 .PP
74 On success,
75 \fBsd_event_source_set_priority()\fR
76 and
77 \fBsd_event_source_get_priority()\fR
78 return a non\-negative integer\&. On failure, they return a negative errno\-style error code\&.
79 .SS "Errors"
80 .PP
81 Returned errors may indicate the following problems:
82 .PP
83 \fB\-EINVAL\fR
84 .RS 4
85 \fIsource\fR
86 is not a valid pointer to an
87 sd_event_source
88 object\&.
89 .RE
90 .PP
91 \fB\-ENOMEM\fR
92 .RS 4
93 Not enough memory\&.
94 .RE
95 .PP
96 \fB\-ESTALE\fR
97 .RS 4
98 The event loop is already terminated\&.
99 .RE
100 .PP
101 \fB\-ECHILD\fR
102 .RS 4
103 The event loop has been created in a different process, library or module instance\&.
104 .RE
105 .SH "NOTES"
106 .PP
107 Functions described here are available as a shared library, which can be compiled against and linked to with the
108 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
109 file\&.
110 .PP
111 The code described here uses
112 \fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
113 \fBsetenv\fR(3)
114 from a parallel thread\&. It is recommended to only do calls to
115 \fBsetenv()\fR
116 from an early phase of the program when no other threads have been started\&.
117 .SH "HISTORY"
118 .PP
119 \fBsd_event_source_set_priority()\fR
120 and
121 \fBsd_event_source_get_priority()\fR
122 were added in version 229\&.
123 .SH "SEE ALSO"
124 .PP
125 \fBsd-event\fR(3), \fBsd_event_add_io\fR(3), \fBsd_event_add_time\fR(3), \fBsd_event_add_signal\fR(3), \fBsd_event_add_child\fR(3), \fBsd_event_add_inotify\fR(3), \fBsd_event_add_defer\fR(3)