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