]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
3a54a157 ZJS |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
db9ecf05 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
dc83f27a LP |
5 | |
6 | <refentry id="sd_event_source_unref" xmlns:xi="http://www.w3.org/2001/XInclude"> | |
7 | ||
8 | <refentryinfo> | |
9 | <title>sd_event_source_unref</title> | |
10 | <productname>systemd</productname> | |
dc83f27a LP |
11 | </refentryinfo> |
12 | ||
13 | <refmeta> | |
14 | <refentrytitle>sd_event_source_unref</refentrytitle> | |
15 | <manvolnum>3</manvolnum> | |
16 | </refmeta> | |
17 | ||
18 | <refnamediv> | |
19 | <refname>sd_event_source_unref</refname> | |
4afd3348 | 20 | <refname>sd_event_source_unrefp</refname> |
dc83f27a | 21 | <refname>sd_event_source_ref</refname> |
afd15bbb | 22 | <refname>sd_event_source_disable_unref</refname> |
aa7585fd | 23 | <refname>sd_event_source_disable_unrefp</refname> |
dc83f27a LP |
24 | |
25 | <refpurpose>Increase or decrease event source reference counters</refpurpose> | |
26 | </refnamediv> | |
27 | ||
28 | <refsynopsisdiv> | |
29 | <funcsynopsis> | |
30 | <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo> | |
31 | ||
32 | <funcprototype> | |
33 | <funcdef>sd_event_source* <function>sd_event_source_unref</function></funcdef> | |
34 | <paramdef>sd_event_source *<parameter>source</parameter></paramdef> | |
35 | </funcprototype> | |
36 | ||
4afd3348 LP |
37 | <funcprototype> |
38 | <funcdef>void <function>sd_event_source_unrefp</function></funcdef> | |
39 | <paramdef>sd_event_source **<parameter>source</parameter></paramdef> | |
40 | </funcprototype> | |
41 | ||
dc83f27a LP |
42 | <funcprototype> |
43 | <funcdef>sd_event_source* <function>sd_event_source_ref</function></funcdef> | |
44 | <paramdef>sd_event_source *<parameter>source</parameter></paramdef> | |
45 | </funcprototype> | |
46 | ||
afd15bbb ZJS |
47 | <funcprototype> |
48 | <funcdef>sd_event_source* <function>sd_event_source_disable_unref</function></funcdef> | |
49 | <paramdef>sd_event_source *<parameter>source</parameter></paramdef> | |
50 | </funcprototype> | |
aa7585fd ZJS |
51 | |
52 | <funcprototype> | |
53 | <funcdef>void <function>sd_event_source_disable_unrefp</function></funcdef> | |
54 | <paramdef>sd_event_source **<parameter>source</parameter></paramdef> | |
55 | </funcprototype> | |
dc83f27a LP |
56 | </funcsynopsis> |
57 | </refsynopsisdiv> | |
58 | ||
59 | <refsect1> | |
60 | <title>Description</title> | |
61 | ||
52e30c6f ZJS |
62 | <para><function>sd_event_source_unref()</function> may be used to decrement by one the internal reference |
63 | counter of the event source object specified as <parameter>source</parameter>. The reference counter is | |
64 | initially set to one, when the event source is created with calls such as | |
65 | <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry> or | |
dc83f27a | 66 | <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>. When |
52e30c6f ZJS |
67 | the reference counter reaches zero, the object is detached from the event loop object and destroyed. |
68 | </para> | |
dc83f27a | 69 | |
4afd3348 LP |
70 | <para><function>sd_event_source_unrefp()</function> is similar to |
71 | <function>sd_event_source_unref()</function> but takes a pointer to a | |
72 | pointer to an <type>sd_event_source</type> object. This call is useful in | |
73 | conjunction with GCC's and LLVM's <ulink | |
74 | url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up | |
75 | Variable Attribute</ulink>. Note that this function is defined as | |
76 | inline function.</para> | |
77 | ||
52e30c6f ZJS |
78 | <para><function>sd_event_source_ref()</function> may be used to increase by one the internal reference |
79 | counter of the event source object specified as <parameter>source</parameter>.</para> | |
dc83f27a | 80 | |
4afd3348 LP |
81 | <para><function>sd_event_source_unref()</function>, |
82 | <function>sd_bus_creds_unrefp()</function> and | |
83 | <function>sd_bus_creds_ref()</function> execute no operation if | |
84 | the passed event source object is | |
85 | <constant>NULL</constant>.</para> | |
dc83f27a | 86 | |
afd15bbb ZJS |
87 | <para>Note that event source objects stay alive and may be dispatched as long as they have a reference |
88 | counter greater than zero. In order to drop a reference of an event source and make sure the associated | |
89 | event source handler function is not called anymore it is recommended to combine a call of | |
dc83f27a | 90 | <function>sd_event_source_unref()</function> with a prior call to |
afd15bbb ZJS |
91 | <function>sd_event_source_set_enabled()</function> with <constant>SD_EVENT_OFF</constant> or call |
92 | <function>sd_event_source_disable_unref()</function>, see below.</para> | |
93 | ||
94 | <para><function>sd_event_source_disable_unref()</function> combines a call to | |
95 | <function>sd_event_source_set_enabled()</function> with <constant>SD_EVENT_OFF</constant> with | |
96 | <function>sd_event_source_unref()</function>. This ensures that the source is disabled before the local | |
97 | reference to it is lost. The <parameter>source</parameter> parameter is allowed to be | |
98 | <constant>NULL</constant>.</para> | |
aa7585fd ZJS |
99 | |
100 | <para><function>sd_event_source_disable_unrefp()</function> is similar to | |
101 | <function>sd_event_source_unrefp()</function>, but in addition disables the source first. This call is | |
102 | useful in conjunction with GCC's and LLVM's | |
103 | <ulink url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up Variable | |
104 | Attribute</ulink>. Note that this function is defined as inline function.</para> | |
dc83f27a LP |
105 | </refsect1> |
106 | ||
107 | <refsect1> | |
108 | <title>Return Value</title> | |
109 | ||
afd15bbb ZJS |
110 | <para><function>sd_event_source_unref()</function> and |
111 | <function>sd_event_source_disable_unref()</function> always return <constant>NULL</constant>. | |
112 | <function>sd_event_source_ref()</function> always returns the event source object passed in.</para> | |
dc83f27a LP |
113 | </refsect1> |
114 | ||
115 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
116 | ||
69106f47 AK |
117 | <refsect1> |
118 | <title>History</title> | |
119 | <para><function>sd_event_source_ref()</function> was added in version 229.</para> | |
120 | <para><function>sd_event_source_unref()</function> was added in version 229.</para> | |
121 | <para><function>sd_event_source_unrefp()</function> was added in version 229.</para> | |
122 | <para><function>sd_event_source_disable_unref()</function> was added in version 243.</para> | |
123 | <para><function>sd_event_source_disable_unrefp()</function> was added in version 243.</para> | |
124 | </refsect1> | |
125 | ||
dc83f27a LP |
126 | <refsect1> |
127 | <title>See Also</title> | |
128 | ||
129 | <para> | |
130 | <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
131 | <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
132 | <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
dc83f27a | 133 | <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
8274a30d LP |
134 | <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
135 | <citerefentry><refentrytitle>sd_event_add_inotify</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
dc83f27a LP |
136 | <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
137 | <citerefentry><refentrytitle>sd_event_source_set_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
138 | </para> | |
139 | </refsect1> | |
140 | ||
141 | </refentry> |