]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_event_source_set_priority.xml
man: use same header for all files
[thirdparty/systemd.git] / man / sd_event_source_set_priority.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
3a54a157
ZJS
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
0307f791 4<!-- SPDX-License-Identifier: LGPL-2.1+ -->
dc83f27a
LP
5
6<refentry id="sd_event_source_set_priority" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8 <refentryinfo>
9 <title>sd_event_source_set_priority</title>
10 <productname>systemd</productname>
dc83f27a
LP
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>sd_event_source_set_priority</refentrytitle>
15 <manvolnum>3</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>sd_event_source_set_priority</refname>
20 <refname>sd_event_source_get_priority</refname>
21 <refname>SD_EVENT_PRIORITY_IMPORTANT</refname>
22 <refname>SD_EVENT_PRIORITY_NORMAL</refname>
23 <refname>SD_EVENT_PRIORITY_IDLE</refname>
24
25 <refpurpose>Set or retrieve the priority of event sources</refpurpose>
26 </refnamediv>
27
28 <refsynopsisdiv>
29 <funcsynopsis>
30 <funcsynopsisinfo>#include &lt;systemd/sd-event.h&gt;</funcsynopsisinfo>
31
32 <funcsynopsisinfo><token>enum</token> {
f2e5f466
ME
33 <constant>SD_EVENT_PRIORITY_IMPORTANT</constant> = -100,
34 <constant>SD_EVENT_PRIORITY_NORMAL</constant> = 0,
35 <constant>SD_EVENT_PRIORITY_IDLE</constant> = 100,
dc83f27a
LP
36};</funcsynopsisinfo>
37
38 <funcprototype>
39 <funcdef>int <function>sd_event_source_set_priority</function></funcdef>
40 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
41 <paramdef>int64_t <parameter>priority</parameter></paramdef>
42 </funcprototype>
43
44 <funcprototype>
45 <funcdef>int <function>sd_event_source_get_priority</function></funcdef>
46 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
47 <paramdef>int64_t *<parameter>priority</parameter></paramdef>
48 </funcprototype>
49
50 </funcsynopsis>
51 </refsynopsisdiv>
52
53 <refsect1>
54 <title>Description</title>
55
56 <para><function>sd_event_source_set_priority()</function> may be
57 used to set the priority for the event source object specified as
58 <parameter>source</parameter>. The priority is specified as an
59 arbitrary signed 64bit integer. The priority is initialized to
60 <constant>SD_EVENT_PRIORITY_NORMAL</constant> (0) when the event
61 source is allocated with a call such as
62 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>
63 or
64 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
65 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
66 event sources' priorities. Event sources with smaller priority
67 values are dispatched first. As well-known points of reference,
68 the constants <constant>SD_EVENT_PRIORITY_IMPORTANT</constant>
69 (-100), <constant>SD_EVENT_PRIORITY_NORMAL</constant> (0) and
70 <constant>SD_EVENT_PRIORITY_IDLE</constant> (100) may be used to
71 indicate event sources that shall be dispatched early, normally or
72 late. It is recommended to specify priorities based on these
ccddd104 73 definitions, and relative to them — however, the full 64bit
dc83f27a
LP
74 signed integer range is available for ordering event
75 sources.</para>
76
77 <para>Priorities define the order in which event sources that have
78 seen events are dispatched. Care should be taken to ensure that
79 high-priority event sources (those with negative priority values
80 assigned) do not cause starvation of low-priority event sources
81 (those with positive priority values assigned).</para>
82
83 <para>The order in which event sources with the same priority are
84 dispatched is undefined, but the event loop generally tries to
85 dispatch them in the order it learnt about events on them. As the
86 backing kernel primitives do not provide accurate information
7f3fdb7f 87 about the order in which events occurred this is not necessarily
dc83f27a
LP
88 reliable. However, it is guaranteed that if events are seen on
89 multiple same-priority event sources at the same time, each one is
90 not dispatched again until all others have been dispatched
2dd67817 91 once. This behavior guarantees that within each priority
dc83f27a
LP
92 particular event sources do not starve or dominate the event
93 loop.</para>
94
1eb54dc6
LP
95 <para>The priority of event sources may be changed at any time of their lifetime, with the exception of inotify
96 event sources (i.e. those created with
97 <citerefentry><refentrytitle>sd_event_add_inotify</refentrytitle><manvolnum>3</manvolnum></citerefentry>) whose
98 priority may only be changed in the time between their initial creation and the first subsequent event loop
99 iteration.</para>
100
dc83f27a
LP
101 <para><function>sd_event_source_get_priority()</function> may be
102 used to query the current priority assigned to the event source
103 object <parameter>source</parameter>.</para>
104 </refsect1>
105
106 <refsect1>
107 <title>Return Value</title>
108
109 <para>On success,
110 <function>sd_event_source_set_priority()</function> and
111 <function>sd_event_source_get_priority()</function> return a
112 non-negative integer. On failure, they return a negative
113 errno-style error code.</para>
114 </refsect1>
115
116 <refsect1>
117 <title>Errors</title>
118
119 <para>Returned errors may indicate the following problems:</para>
120
121 <variablelist>
122 <varlistentry>
123 <term><constant>-EINVAL</constant></term>
124
125 <listitem><para><parameter>source</parameter> is not a valid
126 pointer to an <structname>sd_event_source</structname>
127 object.</para></listitem>
128 </varlistentry>
129
130 <varlistentry>
131 <term><constant>-ENOMEM</constant></term>
132
133 <listitem><para>Not enough memory.</para></listitem>
134 </varlistentry>
135
136 <varlistentry>
137 <term><constant>-ESTALE</constant></term>
138
139 <listitem><para>The event loop is already terminated.</para></listitem>
140
141 </varlistentry>
142
143 <varlistentry>
144 <term><constant>-ECHILD</constant></term>
145
146 <listitem><para>The event loop has been created in a different process.</para></listitem>
147
148 </varlistentry>
149
150 </variablelist>
151 </refsect1>
152
153 <xi:include href="libsystemd-pkgconfig.xml" />
154
155 <refsect1>
156 <title>See Also</title>
157
158 <para>
159 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
160 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
161 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a 162 <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
8274a30d
LP
163 <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
164 <citerefentry><refentrytitle>sd_event_add_inotify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a
LP
165 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>
166 </para>
167 </refsect1>
168
169</refentry>