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_unref" xmlns:xi="http://www.w3.org/2001/XInclude">
27 <title>sd_event_source_unref</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_unref</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_event_source_unref</refname>
47 <refname>sd_event_source_unrefp</refname>
48 <refname>sd_event_source_ref</refname>
50 <refpurpose>Increase or decrease event source reference counters</refpurpose>
55 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
58 <funcdef>sd_event_source* <function>sd_event_source_unref</function></funcdef>
59 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
63 <funcdef>void <function>sd_event_source_unrefp</function></funcdef>
64 <paramdef>sd_event_source **<parameter>source</parameter></paramdef>
68 <funcdef>sd_event_source* <function>sd_event_source_ref</function></funcdef>
69 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
76 <title>Description</title>
78 <para><function>sd_event_source_unref()</function> may be used to
79 decrement by one the reference counter of the event source object
80 specified as <parameter>source</parameter>. The reference counter
81 is initially set to one, when the event source is created with calls
83 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>
85 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>. When
86 the reference counter reaches zero it is removed from its event loop
87 object and destroyed.</para>
89 <para><function>sd_event_source_unrefp()</function> is similar to
90 <function>sd_event_source_unref()</function> but takes a pointer to a
91 pointer to an <type>sd_event_source</type> object. This call is useful in
92 conjunction with GCC's and LLVM's <ulink
93 url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up
94 Variable Attribute</ulink>. Note that this function is defined as
95 inline function.</para>
97 <para><function>sd_event_source_ref()</function> may be used
98 to increase by one the reference counter of the event source object
99 specified as <parameter>source</parameter>.</para>
101 <para><function>sd_event_source_unref()</function>,
102 <function>sd_bus_creds_unrefp()</function> and
103 <function>sd_bus_creds_ref()</function> execute no operation if
104 the passed event source object is
105 <constant>NULL</constant>.</para>
107 <para>Note that event source objects stay alive and may be
108 dispatched as long as they have a reference counter greater than
109 zero. In order to drop a reference of an event source and make
110 sure the associated event source handler function is not called
111 anymore it is recommended to combine a call of
112 <function>sd_event_source_unref()</function> with a prior call to
113 <function>sd_event_source_set_enabled()</function> with
114 <constant>SD_EVENT_OFF</constant>.</para>
118 <title>Return Value</title>
120 <para><function>sd_event_source_unref()</function> always returns
121 <constant>NULL</constant>.
122 <function>sd_event_source_ref()</function> always returns the
123 event source object passed in.</para>
126 <xi:include href="libelogind-pkgconfig.xml" />
129 <title>See Also</title>
132 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
133 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
134 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135 <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
136 <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
137 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
138 <citerefentry><refentrytitle>sd_event_source_set_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>