man-pages/man3/sd_event_source_unref.3.html
2021-03-31 01:06:50 +01:00

185 lines
5.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SD_EVENT_SOURCE_UNREF</TITLE>
</HEAD><BODY>
<H1>SD_EVENT_SOURCE_UNREF</H1>
Section: sd_event_source_unref (3)<BR>Updated: <BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
sd_event_source_unref, sd_event_source_unrefp, sd_event_source_ref, sd_event_source_disable_unref, sd_event_source_disable_unrefp - Increase or decrease event source reference counters
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<B>
</B><PRE>
#include &lt;<A HREF="file:///usr/include/systemd/sd-event.h">systemd/sd-event.h</A>&gt;
</PRE>
<DL COMPACT>
<DT id="1">
<B>sd_event_source* sd_event_source_unref(sd_event_source&nbsp;*</B><I>source</I><B>);</B>
<DT id="2">
<B>void sd_event_source_unrefp(sd_event_source&nbsp;**</B><I>source</I><B>);</B>
<DT id="3">
<B>sd_event_source* sd_event_source_ref(sd_event_source&nbsp;*</B><I>source</I><B>);</B>
<DT id="4">
<B>sd_event_source* sd_event_source_disable_unref(sd_event_source&nbsp;*</B><I>source</I><B>);</B>
<DT id="5">
<B>void sd_event_source_disable_unrefp(sd_event_source&nbsp;**</B><I>source</I><B>);</B>
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
<B>sd_event_source_unref()</B>
<DD>may be used to decrement by one the reference counter of the event source object specified as
<I>source</I>. The reference counter is initially set to one, when the event source is created with calls such as
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_io">sd_event_add_io</A></B>(3)
or
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_time">sd_event_add_time</A></B>(3). When the reference counter reaches zero it is removed from its event loop object and destroyed.
<P>
<B>sd_event_source_unrefp()</B>
is similar to
<B>sd_event_source_unref()</B>
but takes a pointer to a pointer to an
<B>sd_event_source</B>
object. This call is useful in conjunction with GCC's and LLVM's
m[blue]<B>Clean-up Variable Attribute</B>m[]<FONT SIZE="-2">[1]</FONT>. Note that this function is defined as inline function.
<P>
<B>sd_event_source_ref()</B>
may be used to increase by one the reference counter of the event source object specified as
<I>source</I>.
<P>
<B>sd_event_source_unref()</B>,
<B>sd_bus_creds_unrefp()</B>
and
<B>sd_bus_creds_ref()</B>
execute no operation if the passed event source object is
<B>NULL</B>.
<P>
Note that event source objects stay alive and may be dispatched as long as they have a reference counter greater than zero. In order to drop a reference of an event source and make sure the associated event source handler function is not called anymore it is recommended to combine a call of
<B>sd_event_source_unref()</B>
with a prior call to
<B>sd_event_source_set_enabled()</B>
with
<B>SD_EVENT_OFF</B>
or call
<B>sd_event_source_disable_unref()</B>, see below.
<P>
<B>sd_event_source_disable_unref()</B>
combines a call to
<B>sd_event_source_set_enabled()</B>
with
<B>SD_EVENT_OFF</B>
with
<B>sd_event_source_unref()</B>. This ensures that the source is disabled before the local reference to it is lost. The
<I>source</I>
parameter is allowed to be
<B>NULL</B>.
<P>
<B>sd_event_source_disable_unrefp()</B>
is similar to
<B>sd_event_source_unrefp()</B>, but in addition disables the source first. This call is useful in conjunction with GCC's and LLVM's
m[blue]<B>Clean-up Variable Attribute</B>m[]<FONT SIZE="-2">[1]</FONT>. Note that this function is defined as inline function.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
<P>
<B>sd_event_source_unref()</B>
and
<B>sd_event_source_disable_unref()</B>
always return
<B>NULL</B>.
<B>sd_event_source_ref()</B>
always returns the event source object passed in.
<A NAME="lbAF">&nbsp;</A>
<H2>NOTES</H2>
<P>
These APIs are implemented as a shared library, which can be compiled and linked to with the
<B>libsystemd</B>&nbsp;<B><A HREF="/cgi-bin/man/man2html?1+pkg-config">pkg-config</A></B>(1)
file.
<A NAME="lbAG">&nbsp;</A>
<H2>SEE ALSO</H2>
<P>
<B><A HREF="/cgi-bin/man/man2html?3+sd-event">sd-event</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_io">sd_event_add_io</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_time">sd_event_add_time</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_signal">sd_event_add_signal</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_child">sd_event_add_child</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_inotify">sd_event_add_inotify</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_defer">sd_event_add_defer</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_source_set_enabled">sd_event_source_set_enabled</A></B>(3)
<A NAME="lbAH">&nbsp;</A>
<H2>NOTES</H2>
<DL COMPACT>
<DT id="6"> 1.<DD>
Clean-up Variable Attribute
<DL COMPACT><DT id="7"><DD>
<A HREF="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html</A>
</DL>
<P>
</DL>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="8"><A HREF="#lbAB">NAME</A><DD>
<DT id="9"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="10"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="11"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="12"><A HREF="#lbAF">NOTES</A><DD>
<DT id="13"><A HREF="#lbAG">SEE ALSO</A><DD>
<DT id="14"><A HREF="#lbAH">NOTES</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:55 GMT, March 31, 2021
</BODY>
</HTML>