sd_event_add_defer.xml revision f49481d0ca170ea567b46fde6c1c089b1dbb49cb
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek<?xml version='1.0'?> <!--*-nxml-*-->
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-SzmekThis file is part of systemd.
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-SzmekCopyright 2014 Zbigniew Jędrzejewski-Szmek
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmeksystemd is free software; you can redistribute it and/or modify it
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmekunder the terms of the GNU Lesser General Public License as published by
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmekthe Free Software Foundation; either version 2.1 of the License, or
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek(at your option) any later version.
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmeksystemd is distributed in the hope that it will be useful, but
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-SzmekWITHOUT ANY WARRANTY; without even the implied warranty of
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-SzmekMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-SzmekLesser General Public License for more details.
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-SzmekYou should have received a copy of the GNU Lesser General Public License
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmekalong with systemd; If not, see <http://www.gnu.org/licenses/>.
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek<refentry id="sd_event_add_defer" conditional="ENABLE_KDBUS">
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <title>sd_event_add_defer</title>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <productname>systemd</productname>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <surname>Jędrzejewski-Szmek</surname>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <email>zbyszek@in.waw.pl</email>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <refentrytitle>sd_event_add_defer</refentrytitle>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <refname>sd_event_add_defer</refname>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <refname>sd_event_add_post</refname>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <refname>sd_event_add_exit</refname>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <refpurpose>Add static event sources to an event loop</refpurpose>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <refsynopsisdiv>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <funcdef>int <function>sd_event_add_defer</function></funcdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event *<parameter>event</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event_source **<parameter>source</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event_handler_t <parameter>handler</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>void *<parameter>userdata</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek </funcprototype>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <funcdef>int <function>sd_event_add_post</function></funcdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event *<parameter>event</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event_source **<parameter>source</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event_handler_t <parameter>handler</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>void *<parameter>userdata</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek </funcprototype>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <funcdef>int <function>sd_event_add_exit</function></funcdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event *<parameter>event</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event_source **<parameter>source</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event_handler_t <parameter>handler</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>void *<parameter>userdata</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek </funcprototype>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <funcdef>typedef int (*<function>sd_event_handler_t</function>)</funcdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>sd_event_source *<parameter>s</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <paramdef>void *<parameter>userdata</parameter></paramdef>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek </funcprototype>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek </refsynopsisdiv>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <para>Those three functions add new event sources to an event loop
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek object. The event loop is specified in
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <parameter>event</parameter>, the event source is returned in the
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <parameter>source</parameter> parameter. The event sources are
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek enabled statically and will "fire" when the event loop is run and
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek the conditions described below are met. The handler function will
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek be passed the <parameter>userdata</parameter> pointer, which may
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek be chosen freely by the caller.</para>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <para><function>sd_event_add_defer()</function> adds a new event
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek source that will "fire" the next time the event loop is run. By
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek default, the handler will be called once
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek (<constant>SD_EVENT_ONESHOT</constant>).</para>
f49481d0ca170ea567b46fde6c1c089b1dbb49cbTom Gundersen <para><function>sd_event_add_post()</function> adds a new event
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek source that will "fire" if any event handlers are invoked whenever
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek the event loop is run. By default, the source is enabled
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek permanently (<constant>SD_EVENT_ON</constant>).</para>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <para><function>sd_event_add_exit()</function> adds a new event
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek source that will "fire" when the event loop is terminated
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek with <function>sd_event_exit()</function>.</para>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <citerefentry><refentrytitle>sd_event_source_set_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek function may be used to enable the event source permanently
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek (<constant>SD_EVENT_ON</constant>) or to make it fire just once
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek (<constant>SD_EVENT_ONESHOT</constant>). If the handler function
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek returns a negative error code, it will be disabled after the
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek invocation, even if <constant>SD_EVENT_ON</constant> mode is
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <para>On success, this functions return 0 or a positive
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek integer. On failure, they return a negative errno-style error
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <para>Returned errors may indicate the following problems:</para>
8474b70c3a3842cdf3d51f331dd117ab6421f6d0Zbigniew Jędrzejewski-Szmek <term><constant>-ENOMEM</constant></term>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <listitem><para>Not enough memory to allocate an object.</para></listitem>
8474b70c3a3842cdf3d51f331dd117ab6421f6d0Zbigniew Jędrzejewski-Szmek <term><constant>-EINVAL</constant></term>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <listitem><para>An invalid argument has been passed.</para></listitem>
8474b70c3a3842cdf3d51f331dd117ab6421f6d0Zbigniew Jędrzejewski-Szmek <term><constant>-ESTALE</constant></term>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <listitem><para>The event loop is already terminated.</para></listitem>
8474b70c3a3842cdf3d51f331dd117ab6421f6d0Zbigniew Jędrzejewski-Szmek <term><constant>-ECHILD</constant></term>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <listitem><para>The event loop has been created in a different process.</para></listitem>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <para>Functions described here are available as a shared library,
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek which can be compiled and linked to with the
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <constant>libsystemd</constant> <citerefentry
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
4dfefc1914bad6a025e2d6738999e45b74715002Zbigniew Jędrzejewski-Szmek <citerefentry><refentrytitle>sd_event_source_set_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>