]>
Commit | Line | Data |
---|---|---|
60f067b4 JS |
1 | <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> |
2 | a.headerlink { | |
3 | color: #c60f0f; | |
4 | font-size: 0.8em; | |
5 | padding: 0 4px 0 4px; | |
6 | text-decoration: none; | |
7 | visibility: hidden; | |
8 | } | |
9 | ||
10 | a.headerlink:hover { | |
11 | background-color: #c60f0f; | |
12 | color: white; | |
13 | } | |
14 | ||
15 | h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink { | |
16 | visibility: visible; | |
17 | } | |
18 | </style><a href="index.html">Index </a>· | |
19 | <a href="systemd.directives.html">Directives </a>· | |
20 | <a href="../python-systemd/index.html">Python </a>· | |
21 | <a href="../libudev/index.html">libudev </a>· | |
e735f4d4 | 22 | <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 219</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="idm139650549886336"></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 |
60f067b4 JS |
23 | loop object. The event loop object is returned in the |
24 | <em class="parameter"><code>event</code></em> parameter. After use, drop | |
25 | the returned reference with | |
26 | <code class="function">sd_event_unref()</code>. When the last reference is | |
5eef597e | 27 | dropped, the object is freed.</p><p><code class="function">sd_event_default()</code> acquires a reference |
60f067b4 JS |
28 | to the default event loop object of the calling thread, possibly |
29 | allocating a new object if no default event loop object has been | |
30 | allocated yet for the thread. After use, drop the returned | |
31 | reference with <code class="function">sd_event_unref()</code>. When the | |
32 | last reference is dropped, the event loop is freed. If this | |
33 | function is called while the object returned from a previous call | |
34 | from the same thread is still referenced, the same object is | |
35 | returned again, but the reference is increased by one. It is | |
36 | recommended to use this call instead of | |
37 | <code class="function">sd_event_new()</code> in order to share event loop | |
38 | objects between various components that are dispatched in the same | |
5eef597e MP |
39 | thread. All threads have exactly either zero or one default event loop |
40 | objects associated, but never more.</p><p><code class="function">sd_event_ref()</code> increases the reference | |
41 | count of the specified event loop object by one.</p><p><code class="function">sd_event_unref()</code> decreases the | |
42 | reference count of the specified event loop object by one. If | |
43 | the count hits zero, the object is freed. Note that it | |
60f067b4 JS |
44 | is freed regardless of whether it is the default event loop object for a |
45 | thread or not. This means that allocating an event loop with | |
46 | <code class="function">sd_event_default()</code>, then releasing it, and | |
47 | then acquiring a new one with | |
48 | <code class="function">sd_event_default()</code> will result in two | |
5eef597e | 49 | distinct objects. Note that in order to free an event loop object, |
60f067b4 | 50 | all remaining event sources of the event loop also need to be |
e735f4d4 | 51 | freed as each keeps a reference to it.</p></div><div class="refsect1"><a name="idm139650549876304"></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 |
60f067b4 JS |
52 | <code class="function">sd_event_default()</code> return 0 or a positive |
53 | integer. On failure, they return a negative errno-style error | |
54 | code. <code class="function">sd_event_ref()</code> always returns a pointer | |
55 | to the event loop object passed | |
56 | in. <code class="function">sd_event_unref()</code> always returns | |
e735f4d4 | 57 | <code class="constant">NULL</code>.</p></div><div class="refsect1"><a name="idm139650553826032"></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="idm139650553821536"></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 |
60f067b4 JS |
58 | described here are available as a shared library, which can be |
59 | compiled and linked to with the | |
5eef597e | 60 | <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> |
e735f4d4 | 61 | file.</p></div><div class="refsect1"><a name="idm139650553818048"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p> |
60f067b4 JS |
62 | <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>, |
63 | <a href="sd-event.html"><span class="citerefentry"><span class="refentrytitle">sd-event</span>(3)</span></a>, | |
64 | <a href="sd_event_add_io.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_io</span>(3)</span></a>, | |
65 | <a href="sd_event_add_time.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_time</span>(3)</span></a>, | |
66 | <a href="sd_event_add_signal.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_signal</span>(3)</span></a>, | |
67 | <a href="sd_event_add_child.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_child</span>(3)</span></a>, | |
68 | <a href="sd_event_add_defer.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_defer</span>(3)</span></a>, | |
69 | <a href="sd_event_add_post.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_post</span>(3)</span></a>, | |
70 | <a href="sd_event_add_exit.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_exit</span>(3)</span></a> | |
71 | </p></div></div></body></html> |