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">
6 This file is part of elogind.
8 Copyright 2015 Lennart Poettering
10 elogind is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 elogind is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with elogind; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_event_source_set_priority" xmlns:xi="http://www.w3.org/2001/XInclude">
27 <title>sd_event_source_set_priority</title>
28 <productname>elogind</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_event_source_set_priority</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_event_source_set_priority</refname>
47 <refname>sd_event_source_get_priority</refname>
48 <refname>SD_EVENT_PRIORITY_IMPORTANT</refname>
49 <refname>SD_EVENT_PRIORITY_NORMAL</refname>
50 <refname>SD_EVENT_PRIORITY_IDLE</refname>
52 <refpurpose>Set or retrieve the priority of event sources</refpurpose>
57 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
59 <funcsynopsisinfo><token>enum</token> {
60 <constant>SD_EVENT_PRIORITY_IMPORTANT</constant> = -100,
61 <constant>SD_EVENT_PRIORITY_NORMAL</constant> = 0,
62 <constant>SD_EVENT_PRIORITY_IDLE</constant> = 100,
66 <funcdef>int <function>sd_event_source_set_priority</function></funcdef>
67 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
68 <paramdef>int64_t <parameter>priority</parameter></paramdef>
72 <funcdef>int <function>sd_event_source_get_priority</function></funcdef>
73 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
74 <paramdef>int64_t *<parameter>priority</parameter></paramdef>
81 <title>Description</title>
83 <para><function>sd_event_source_set_priority()</function> may be
84 used to set the priority for the event source object specified as
85 <parameter>source</parameter>. The priority is specified as an
86 arbitrary signed 64bit integer. The priority is initialized to
87 <constant>SD_EVENT_PRIORITY_NORMAL</constant> (0) when the event
88 source is allocated with a call such as
89 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>
91 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
92 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
93 event sources' priorities. Event sources with smaller priority
94 values are dispatched first. As well-known points of reference,
95 the constants <constant>SD_EVENT_PRIORITY_IMPORTANT</constant>
96 (-100), <constant>SD_EVENT_PRIORITY_NORMAL</constant> (0) and
97 <constant>SD_EVENT_PRIORITY_IDLE</constant> (100) may be used to
98 indicate event sources that shall be dispatched early, normally or
99 late. It is recommended to specify priorities based on these
100 definitions, and relative to them — however, the full 64bit
101 signed integer range is available for ordering event
104 <para>Priorities define the order in which event sources that have
105 seen events are dispatched. Care should be taken to ensure that
106 high-priority event sources (those with negative priority values
107 assigned) do not cause starvation of low-priority event sources
108 (those with positive priority values assigned).</para>
110 <para>The order in which event sources with the same priority are
111 dispatched is undefined, but the event loop generally tries to
112 dispatch them in the order it learnt about events on them. As the
113 backing kernel primitives do not provide accurate information
114 about the order in which events occurred this is not necessarily
115 reliable. However, it is guaranteed that if events are seen on
116 multiple same-priority event sources at the same time, each one is
117 not dispatched again until all others have been dispatched
118 once. This behavior guarantees that within each priority
119 particular event sources do not starve or dominate the event
122 <para><function>sd_event_source_get_priority()</function> may be
123 used to query the current priority assigned to the event source
124 object <parameter>source</parameter>.</para>
128 <title>Return Value</title>
131 <function>sd_event_source_set_priority()</function> and
132 <function>sd_event_source_get_priority()</function> return a
133 non-negative integer. On failure, they return a negative
134 errno-style error code.</para>
138 <title>Errors</title>
140 <para>Returned errors may indicate the following problems:</para>
144 <term><constant>-EINVAL</constant></term>
146 <listitem><para><parameter>source</parameter> is not a valid
147 pointer to an <structname>sd_event_source</structname>
148 object.</para></listitem>
152 <term><constant>-ENOMEM</constant></term>
154 <listitem><para>Not enough memory.</para></listitem>
158 <term><constant>-ESTALE</constant></term>
160 <listitem><para>The event loop is already terminated.</para></listitem>
165 <term><constant>-ECHILD</constant></term>
167 <listitem><para>The event loop has been created in a different process.</para></listitem>
174 <xi:include href="libelogind-pkgconfig.xml" />
177 <title>See Also</title>
180 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
181 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
182 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
183 <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
184 <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
185 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>