1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_event_new</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none;
visibility: hidden;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
}
h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
visibility: visible;
}
</style><a href="index.html">Index </a>·
<a href="systemd.directives.html">Directives </a>·
<a href="../python-systemd/index.html">Python </a>·
<span style="float:right">systemd 221</span><hr><div class="refentry"><a name="sd_event_new"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_event_new, sd_event_default, sd_event_ref, sd_event_unref — Acquire and release an event loop object</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <systemd/sd-bus.h></pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_event_new</b>(</code></td><td>sd_bus **<var class="pdparam">event</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_event_default</b>(</code></td><td>sd_bus **<var class="pdparam">event</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">sd_bus *<b class="fsfunc">sd_event_ref</b>(</code></td><td>sd_bus *<var class="pdparam">event</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">sd_bus *<b class="fsfunc">sd_event_unref</b>(</code></td><td>sd_bus *<var class="pdparam">event</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm47172650131744"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><code class="function">sd_event_new()</code> allocates a new event
loop object. The event loop object is returned in the
<em class="parameter"><code>event</code></em> parameter. After use, drop
the returned reference with
<code class="function">sd_event_unref()</code>. When the last reference is
dropped, the object is freed.</p><p><code class="function">sd_event_default()</code> acquires a reference
to the default event loop object of the calling thread, possibly
allocating a new object if no default event loop object has been
allocated yet for the thread. After use, drop the returned
reference with <code class="function">sd_event_unref()</code>. When the
last reference is dropped, the event loop is freed. If this
function is called while the object returned from a previous call
from the same thread is still referenced, the same object is
returned again, but the reference is increased by one. It is
recommended to use this call instead of
<code class="function">sd_event_new()</code> in order to share event loop
objects between various components that are dispatched in the same
thread. All threads have exactly either zero or one default event loop
objects associated, but never more.</p><p><code class="function">sd_event_ref()</code> increases the reference
count of the specified event loop object by one.</p><p><code class="function">sd_event_unref()</code> decreases the
reference count of the specified event loop object by one. If
the count hits zero, the object is freed. Note that it
is freed regardless of whether it is the default event loop object for a
thread or not. This means that allocating an event loop with
<code class="function">sd_event_default()</code>, then releasing it, and
then acquiring a new one with
<code class="function">sd_event_default()</code> will result in two
distinct objects. Note that in order to free an event loop object,
all remaining event sources of the event loop also need to be
freed as each keeps a reference to it.</p></div><div class="refsect1"><a name="idm47172650122384"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value">¶</a></h2><p>On success, <code class="function">sd_event_new()</code> and
<code class="function">sd_event_default()</code> return 0 or a positive
integer. On failure, they return a negative errno-style error
code. <code class="function">sd_event_ref()</code> always returns a pointer
to the event loop object passed
in. <code class="function">sd_event_unref()</code> always returns
<code class="constant">NULL</code>.</p></div><div class="refsect1"><a name="idm47172650118240"></a><h2 id="Errors">Errors<a class="headerlink" title="Permalink to this headline" href="#Errors">¶</a></h2><p>Returned errors may indicate the following problems:</p><div class="variablelist"><dl class="variablelist"><dt id="-ENOMEM"><span class="term"><code class="constant">-ENOMEM</code></span><a class="headerlink" title="Permalink to this term" href="#-ENOMEM">¶</a></dt><dd><p>Not enough memory to allocate the object.</p></dd><dt id="-EMFILE"><span class="term"><code class="constant">-EMFILE</code></span><a class="headerlink" title="Permalink to this term" href="#-EMFILE">¶</a></dt><dd><p>The maximum number of event loops has been allocated.</p></dd></dl></div></div><div class="refsect1"><a name="idm47172650113888"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes">¶</a></h2><p><code class="function">sd_event_new()</code> and the other functions
described here are available as a shared library, which can be
compiled and linked to with the
<code class="constant">libsystemd</code> <a href="http://linux.die.net/man/1/pkg-config"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a>
file.</p></div><div class="refsect1"><a name="idm47172650110704"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p>
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
<a href="sd-event.html"><span class="citerefentry"><span class="refentrytitle">sd-event</span>(3)</span></a>,
<a href="sd_event_add_io.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_io</span>(3)</span></a>,
<a href="sd_event_add_time.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_time</span>(3)</span></a>,
<a href="sd_event_add_signal.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_signal</span>(3)</span></a>,
<a href="sd_event_add_child.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_child</span>(3)</span></a>,
<a href="sd_event_add_defer.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_defer</span>(3)</span></a>,
<a href="sd_event_add_post.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_post</span>(3)</span></a>,
<a href="sd_event_add_exit.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_exit</span>(3)</span></a>
</p></div></div></body></html>
|