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