]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_event_source_set_priority.xml
Merge pull request #8676 from keszybz/drop-license-boilerplate
[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><function>sd_event_source_get_priority()</function> may be
112 used to query the current priority assigned to the event source
113 object <parameter>source</parameter>.</para>
114 </refsect1>
115
116 <refsect1>
117 <title>Return Value</title>
118
119 <para>On success,
120 <function>sd_event_source_set_priority()</function> and
121 <function>sd_event_source_get_priority()</function> return a
122 non-negative integer. On failure, they return a negative
123 errno-style error code.</para>
124 </refsect1>
125
126 <refsect1>
127 <title>Errors</title>
128
129 <para>Returned errors may indicate the following problems:</para>
130
131 <variablelist>
132 <varlistentry>
133 <term><constant>-EINVAL</constant></term>
134
135 <listitem><para><parameter>source</parameter> is not a valid
136 pointer to an <structname>sd_event_source</structname>
137 object.</para></listitem>
138 </varlistentry>
139
140 <varlistentry>
141 <term><constant>-ENOMEM</constant></term>
142
143 <listitem><para>Not enough memory.</para></listitem>
144 </varlistentry>
145
146 <varlistentry>
147 <term><constant>-ESTALE</constant></term>
148
149 <listitem><para>The event loop is already terminated.</para></listitem>
150
151 </varlistentry>
152
153 <varlistentry>
154 <term><constant>-ECHILD</constant></term>
155
156 <listitem><para>The event loop has been created in a different process.</para></listitem>
157
158 </varlistentry>
159
160 </variablelist>
161 </refsect1>
162
163 <xi:include href="libsystemd-pkgconfig.xml" />
164
165 <refsect1>
166 <title>See Also</title>
167
168 <para>
169 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
170 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
171 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
172 <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
173 <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
174 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>
175 </para>
176 </refsect1>
177
178 </refentry>