| Current File : //usr/share/doc/dbus/api/dbus-threads_8c_source.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>D-Bus: dbus-threads.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">D-Bus
 <span id="projectnumber">1.8.20</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.6.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<div class="title">dbus-threads.c</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/* dbus-threads.h D-Bus threads handling</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002, 2003, 2006 Red Hat Inc.</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * Licensed under the Academic Free License version 2.1</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00009"></a>00009 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00010"></a>00010 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00011"></a>00011 <span class="comment"> * (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00016"></a>00016 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> * </span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00019"></a>00019 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00021"></a>00021 <span class="comment"> *</span>
<a name="l00022"></a>00022 <span class="comment"> */</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include <config.h></span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "dbus-threads.h"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "dbus-internals.h"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "dbus-threads-internal.h"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "dbus-list.h"</span>
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="keyword">static</span> <span class="keywordtype">int</span> thread_init_generation = 0;
<a name="l00030"></a>00030
<a name="l00052"></a>00052 <span class="keywordtype">void</span>
<a name="l00053"></a><a class="code" href="group__DBusThreadsInternals.html#ga191deedb97c76fae82bdbc8e1559a849">00053</a> <a class="code" href="group__DBusThreadsInternals.html#ga191deedb97c76fae82bdbc8e1559a849" title="Creates a new mutex or creates a no-op mutex if threads are not initialized.">_dbus_rmutex_new_at_location</a> (<a class="code" href="structDBusRMutex.html">DBusRMutex</a> **location_p)
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055 _dbus_assert (location_p != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusThreads.html#ga33b6cf3b8f1e41bad5508f84758818a7" title="Initializes threads.">dbus_threads_init_default</a> ())
<a name="l00058"></a>00058 {
<a name="l00059"></a>00059 *location_p = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00060"></a>00060 <span class="keywordflow">return</span>;
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062
<a name="l00063"></a>00063 *location_p = _dbus_platform_rmutex_new ();
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065
<a name="l00076"></a>00076 <span class="keywordtype">void</span>
<a name="l00077"></a><a class="code" href="group__DBusThreadsInternals.html#ga89495162caac2ace36c6b9c2031bc962">00077</a> <a class="code" href="group__DBusThreadsInternals.html#ga89495162caac2ace36c6b9c2031bc962" title="Creates a new mutex or creates a no-op mutex if threads are not initialized.">_dbus_cmutex_new_at_location</a> (<a class="code" href="structDBusCMutex.html">DBusCMutex</a> **location_p)
<a name="l00078"></a>00078 {
<a name="l00079"></a>00079 _dbus_assert (location_p != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusThreads.html#ga33b6cf3b8f1e41bad5508f84758818a7" title="Initializes threads.">dbus_threads_init_default</a> ())
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083 *location_p = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00084"></a>00084 <span class="keywordflow">return</span>;
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086
<a name="l00087"></a>00087 *location_p = _dbus_platform_cmutex_new ();
<a name="l00088"></a>00088 }
<a name="l00089"></a>00089
<a name="l00093"></a>00093 <span class="keywordtype">void</span>
<a name="l00094"></a><a class="code" href="group__DBusThreadsInternals.html#gae1c95a3f47bcc78d32fc0a5a8ed37c91">00094</a> <a class="code" href="group__DBusThreadsInternals.html#gae1c95a3f47bcc78d32fc0a5a8ed37c91" title="Frees a DBusRMutex; does nothing if passed a NULL pointer.">_dbus_rmutex_free_at_location</a> (<a class="code" href="structDBusRMutex.html">DBusRMutex</a> **location_p)
<a name="l00095"></a>00095 {
<a name="l00096"></a>00096 <span class="keywordflow">if</span> (location_p == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00097"></a>00097 <span class="keywordflow">return</span>;
<a name="l00098"></a>00098
<a name="l00099"></a>00099 <span class="keywordflow">if</span> (*location_p != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00100"></a>00100 _dbus_platform_rmutex_free (*location_p);
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102
<a name="l00106"></a>00106 <span class="keywordtype">void</span>
<a name="l00107"></a><a class="code" href="group__DBusThreadsInternals.html#ga20ec8aeb88b1f65445a4d3c1c0bd0048">00107</a> <a class="code" href="group__DBusThreadsInternals.html#ga20ec8aeb88b1f65445a4d3c1c0bd0048" title="Frees a DBusCMutex; does nothing if passed a NULL pointer.">_dbus_cmutex_free_at_location</a> (<a class="code" href="structDBusCMutex.html">DBusCMutex</a> **location_p)
<a name="l00108"></a>00108 {
<a name="l00109"></a>00109 <span class="keywordflow">if</span> (location_p == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00110"></a>00110 <span class="keywordflow">return</span>;
<a name="l00111"></a>00111
<a name="l00112"></a>00112 <span class="keywordflow">if</span> (*location_p != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00113"></a>00113 _dbus_platform_cmutex_free (*location_p);
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115
<a name="l00121"></a>00121 <span class="keywordtype">void</span>
<a name="l00122"></a><a class="code" href="group__DBusThreadsInternals.html#gaeb20c411a096aaf067918eb574f121d5">00122</a> <a class="code" href="group__DBusThreadsInternals.html#gaeb20c411a096aaf067918eb574f121d5" title="Locks a mutex.">_dbus_rmutex_lock</a> (<a class="code" href="structDBusRMutex.html">DBusRMutex</a> *mutex)
<a name="l00123"></a>00123 {
<a name="l00124"></a>00124 <span class="keywordflow">if</span> (mutex == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00125"></a>00125 <span class="keywordflow">return</span>;
<a name="l00126"></a>00126
<a name="l00127"></a>00127 _dbus_platform_rmutex_lock (mutex);
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129
<a name="l00135"></a>00135 <span class="keywordtype">void</span>
<a name="l00136"></a><a class="code" href="group__DBusThreadsInternals.html#gabea1bdc19c155bca909839090c05eee2">00136</a> <a class="code" href="group__DBusThreadsInternals.html#gabea1bdc19c155bca909839090c05eee2" title="Locks a mutex.">_dbus_cmutex_lock</a> (<a class="code" href="structDBusCMutex.html">DBusCMutex</a> *mutex)
<a name="l00137"></a>00137 {
<a name="l00138"></a>00138 <span class="keywordflow">if</span> (mutex == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00139"></a>00139 <span class="keywordflow">return</span>;
<a name="l00140"></a>00140
<a name="l00141"></a>00141 _dbus_platform_cmutex_lock (mutex);
<a name="l00142"></a>00142 }
<a name="l00143"></a>00143
<a name="l00149"></a>00149 <span class="keywordtype">void</span>
<a name="l00150"></a><a class="code" href="group__DBusThreadsInternals.html#ga5946b9a5ea3e12a81a798b575b45c62f">00150</a> <a class="code" href="group__DBusThreadsInternals.html#ga5946b9a5ea3e12a81a798b575b45c62f" title="Unlocks a mutex.">_dbus_rmutex_unlock</a> (<a class="code" href="structDBusRMutex.html">DBusRMutex</a> *mutex)
<a name="l00151"></a>00151 {
<a name="l00152"></a>00152 <span class="keywordflow">if</span> (mutex == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00153"></a>00153 <span class="keywordflow">return</span>;
<a name="l00154"></a>00154
<a name="l00155"></a>00155 _dbus_platform_rmutex_unlock (mutex);
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157
<a name="l00163"></a>00163 <span class="keywordtype">void</span>
<a name="l00164"></a><a class="code" href="group__DBusThreadsInternals.html#gad199edcd1bb88cfd2e9dcfb47cbc732f">00164</a> <a class="code" href="group__DBusThreadsInternals.html#gad199edcd1bb88cfd2e9dcfb47cbc732f" title="Unlocks a mutex.">_dbus_cmutex_unlock</a> (<a class="code" href="structDBusCMutex.html">DBusCMutex</a> *mutex)
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166 <span class="keywordflow">if</span> (mutex == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00167"></a>00167 <span class="keywordflow">return</span>;
<a name="l00168"></a>00168
<a name="l00169"></a>00169 _dbus_platform_cmutex_unlock (mutex);
<a name="l00170"></a>00170 }
<a name="l00171"></a>00171
<a name="l00180"></a>00180 <a class="code" href="structDBusCondVar.html">DBusCondVar</a> *
<a name="l00181"></a><a class="code" href="group__DBusThreadsInternals.html#ga454b138bcbd419d38b3da6b707e46998">00181</a> <a class="code" href="group__DBusThreadsInternals.html#ga454b138bcbd419d38b3da6b707e46998" title="Creates a new condition variable using the function supplied to dbus_threads_init(), or creates a no-op condition variable if threads are not initialized.">_dbus_condvar_new</a> (<span class="keywordtype">void</span>)
<a name="l00182"></a>00182 {
<a name="l00183"></a>00183 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusThreads.html#ga33b6cf3b8f1e41bad5508f84758818a7" title="Initializes threads.">dbus_threads_init_default</a> ())
<a name="l00184"></a>00184 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <span class="keywordflow">return</span> _dbus_platform_condvar_new ();
<a name="l00187"></a>00187 }
<a name="l00188"></a>00188
<a name="l00189"></a>00189
<a name="l00198"></a>00198 <span class="keywordtype">void</span>
<a name="l00199"></a><a class="code" href="group__DBusThreadsInternals.html#ga859c5830e3c212323c1d6dafee3858a1">00199</a> <a class="code" href="group__DBusThreadsInternals.html#ga859c5830e3c212323c1d6dafee3858a1" title="This does the same thing as _dbus_condvar_new.">_dbus_condvar_new_at_location</a> (<a class="code" href="structDBusCondVar.html">DBusCondVar</a> **location_p)
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201 _dbus_assert (location_p != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00202"></a>00202
<a name="l00203"></a>00203 *location_p = <a class="code" href="group__DBusThreadsInternals.html#ga454b138bcbd419d38b3da6b707e46998" title="Creates a new condition variable using the function supplied to dbus_threads_init(), or creates a no-op condition variable if threads are not initialized.">_dbus_condvar_new</a>();
<a name="l00204"></a>00204 }
<a name="l00205"></a>00205
<a name="l00206"></a>00206
<a name="l00211"></a>00211 <span class="keywordtype">void</span>
<a name="l00212"></a><a class="code" href="group__DBusThreadsInternals.html#gaff04b7377b6ab0cc22fee6a2811dde84">00212</a> <a class="code" href="group__DBusThreadsInternals.html#gaff04b7377b6ab0cc22fee6a2811dde84" title="Frees a conditional variable created with dbus_condvar_new(); does nothing if passed a NULL pointer...">_dbus_condvar_free</a> (<a class="code" href="structDBusCondVar.html">DBusCondVar</a> *cond)
<a name="l00213"></a>00213 {
<a name="l00214"></a>00214 <span class="keywordflow">if</span> (cond == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00215"></a>00215 <span class="keywordflow">return</span>;
<a name="l00216"></a>00216
<a name="l00217"></a>00217 _dbus_platform_condvar_free (cond);
<a name="l00218"></a>00218 }
<a name="l00219"></a>00219
<a name="l00223"></a>00223 <span class="keywordtype">void</span>
<a name="l00224"></a><a class="code" href="group__DBusThreadsInternals.html#ga29444a34b569fca22fac48067832aacd">00224</a> <a class="code" href="group__DBusThreadsInternals.html#ga29444a34b569fca22fac48067832aacd" title="Frees a condition variable; does nothing if passed a NULL pointer.">_dbus_condvar_free_at_location</a> (<a class="code" href="structDBusCondVar.html">DBusCondVar</a> **location_p)
<a name="l00225"></a>00225 {
<a name="l00226"></a>00226 <span class="keywordflow">if</span> (location_p == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00227"></a>00227 <span class="keywordflow">return</span>;
<a name="l00228"></a>00228
<a name="l00229"></a>00229 <span class="keywordflow">if</span> (*location_p != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00230"></a>00230 _dbus_platform_condvar_free (*location_p);
<a name="l00231"></a>00231 }
<a name="l00232"></a>00232
<a name="l00239"></a>00239 <span class="keywordtype">void</span>
<a name="l00240"></a><a class="code" href="group__DBusThreadsInternals.html#ga6938b8a4547ce48290615990f64bd3bb">00240</a> <a class="code" href="group__DBusThreadsInternals.html#ga6938b8a4547ce48290615990f64bd3bb" title="Atomically unlocks the mutex and waits for the conditions variable to be signalled.">_dbus_condvar_wait</a> (<a class="code" href="structDBusCondVar.html">DBusCondVar</a> *cond,
<a name="l00241"></a>00241 <a class="code" href="structDBusCMutex.html">DBusCMutex</a> *mutex)
<a name="l00242"></a>00242 {
<a name="l00243"></a>00243 <span class="keywordflow">if</span> (cond == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> || mutex == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00244"></a>00244 <span class="keywordflow">return</span>;
<a name="l00245"></a>00245
<a name="l00246"></a>00246 _dbus_platform_condvar_wait (cond, mutex);
<a name="l00247"></a>00247 }
<a name="l00248"></a>00248
<a name="l00260"></a>00260 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00261"></a><a class="code" href="group__DBusThreadsInternals.html#ga918e53c2abc48ff496f3c75566ba8bd3">00261</a> <a class="code" href="group__DBusThreadsInternals.html#ga918e53c2abc48ff496f3c75566ba8bd3" title="Atomically unlocks the mutex and waits for the conditions variable to be signalled, or for a timeout.">_dbus_condvar_wait_timeout</a> (<a class="code" href="structDBusCondVar.html">DBusCondVar</a> *cond,
<a name="l00262"></a>00262 <a class="code" href="structDBusCMutex.html">DBusCMutex</a> *mutex,
<a name="l00263"></a>00263 <span class="keywordtype">int</span> timeout_milliseconds)
<a name="l00264"></a>00264 {
<a name="l00265"></a>00265 <span class="keywordflow">if</span> (cond == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> || mutex == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00266"></a>00266 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00267"></a>00267
<a name="l00268"></a>00268 <span class="keywordflow">return</span> _dbus_platform_condvar_wait_timeout (cond, mutex,
<a name="l00269"></a>00269 timeout_milliseconds);
<a name="l00270"></a>00270 }
<a name="l00271"></a>00271
<a name="l00277"></a>00277 <span class="keywordtype">void</span>
<a name="l00278"></a><a class="code" href="group__DBusThreadsInternals.html#ga8af2fd84773022e7e7ce1f21f0126203">00278</a> <a class="code" href="group__DBusThreadsInternals.html#ga8af2fd84773022e7e7ce1f21f0126203" title="If there are threads waiting on the condition variable, wake up exactly one.">_dbus_condvar_wake_one</a> (<a class="code" href="structDBusCondVar.html">DBusCondVar</a> *cond)
<a name="l00279"></a>00279 {
<a name="l00280"></a>00280 <span class="keywordflow">if</span> (cond == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00281"></a>00281 <span class="keywordflow">return</span>;
<a name="l00282"></a>00282
<a name="l00283"></a>00283 _dbus_platform_condvar_wake_one (cond);
<a name="l00284"></a>00284 }
<a name="l00285"></a>00285
<a name="l00286"></a>00286 <span class="keyword">static</span> <a class="code" href="structDBusRMutex.html">DBusRMutex</a> *global_locks[_DBUS_N_GLOBAL_LOCKS] = { <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> };
<a name="l00287"></a>00287
<a name="l00288"></a>00288 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00289"></a>00289 shutdown_global_locks (<span class="keywordtype">void</span> *nil)
<a name="l00290"></a>00290 {
<a name="l00291"></a>00291 <span class="keywordtype">int</span> i;
<a name="l00292"></a>00292
<a name="l00293"></a>00293 <span class="keywordflow">for</span> (i = 0; i < _DBUS_N_GLOBAL_LOCKS; i++)
<a name="l00294"></a>00294 {
<a name="l00295"></a>00295 _dbus_assert (global_locks[i] != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00296"></a>00296 _dbus_platform_rmutex_free (global_locks[i]);
<a name="l00297"></a>00297 global_locks[i] = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00298"></a>00298 }
<a name="l00299"></a>00299 }
<a name="l00300"></a>00300
<a name="l00301"></a>00301 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00302"></a>00302 init_global_locks (<span class="keywordtype">void</span>)
<a name="l00303"></a>00303 {
<a name="l00304"></a>00304 <span class="keywordtype">int</span> i;
<a name="l00305"></a>00305 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> ok;
<a name="l00306"></a>00306
<a name="l00307"></a>00307 <span class="keywordflow">for</span> (i = 0; i < _DBUS_N_GLOBAL_LOCKS; i++)
<a name="l00308"></a>00308 {
<a name="l00309"></a>00309 _dbus_assert (global_locks[i] == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00310"></a>00310
<a name="l00311"></a>00311 global_locks[i] = _dbus_platform_rmutex_new ();
<a name="l00312"></a>00312
<a name="l00313"></a>00313 <span class="keywordflow">if</span> (global_locks[i] == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00314"></a>00314 <span class="keywordflow">goto</span> failed;
<a name="l00315"></a>00315 }
<a name="l00316"></a>00316
<a name="l00317"></a>00317 _dbus_platform_rmutex_lock (global_locks[_DBUS_LOCK_shutdown_funcs]);
<a name="l00318"></a>00318 ok = _dbus_register_shutdown_func_unlocked (shutdown_global_locks, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00319"></a>00319 _dbus_platform_rmutex_unlock (global_locks[_DBUS_LOCK_shutdown_funcs]);
<a name="l00320"></a>00320
<a name="l00321"></a>00321 <span class="keywordflow">if</span> (!ok)
<a name="l00322"></a>00322 <span class="keywordflow">goto</span> failed;
<a name="l00323"></a>00323
<a name="l00324"></a>00324 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00325"></a>00325
<a name="l00326"></a>00326 failed:
<a name="l00327"></a>00327 <span class="keywordflow">for</span> (i = i - 1; i >= 0; i--)
<a name="l00328"></a>00328 {
<a name="l00329"></a>00329 _dbus_platform_rmutex_free (global_locks[i]);
<a name="l00330"></a>00330 global_locks[i] = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00331"></a>00331 }
<a name="l00332"></a>00332
<a name="l00333"></a>00333 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00334"></a>00334 }
<a name="l00335"></a>00335
<a name="l00336"></a>00336 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00337"></a>00337 _dbus_lock (DBusGlobalLock <a class="code" href="structDBusCMutex.html#aee2330c4dab1d863fdb5c52fbcfc0944" title="the lock">lock</a>)
<a name="l00338"></a>00338 {
<a name="l00339"></a>00339 _dbus_assert (lock >= 0);
<a name="l00340"></a>00340 _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS);
<a name="l00341"></a>00341
<a name="l00342"></a>00342 <span class="keywordflow">if</span> (thread_init_generation != <a class="code" href="group__DBusMemoryInternals.html#ga7c224d82013e2bdc181c1d85dcb6f295" title="_dbus_current_generation is used to track each time that dbus_shutdown() is called, so we can reinit things after it's been called.">_dbus_current_generation</a> &&
<a name="l00343"></a>00343 !<a class="code" href="group__DBusThreads.html#ga33b6cf3b8f1e41bad5508f84758818a7" title="Initializes threads.">dbus_threads_init_default</a> ())
<a name="l00344"></a>00344 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00345"></a>00345
<a name="l00346"></a>00346 _dbus_platform_rmutex_lock (global_locks[lock]);
<a name="l00347"></a>00347 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00348"></a>00348 }
<a name="l00349"></a>00349
<a name="l00350"></a>00350 <span class="keywordtype">void</span>
<a name="l00351"></a>00351 _dbus_unlock (DBusGlobalLock lock)
<a name="l00352"></a>00352 {
<a name="l00353"></a>00353 _dbus_assert (lock >= 0);
<a name="l00354"></a>00354 _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS);
<a name="l00355"></a>00355
<a name="l00356"></a>00356 _dbus_platform_rmutex_unlock (global_locks[lock]);
<a name="l00357"></a>00357 }
<a name="l00358"></a>00358 <span class="comment">/* end of internals */</span>
<a name="l00360"></a>00360
<a name="l00390"></a>00390 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00391"></a><a class="code" href="group__DBusThreads.html#gac7b8a7001befc3eaa8c6b043151008dc">00391</a> <a class="code" href="group__DBusThreads.html#gac7b8a7001befc3eaa8c6b043151008dc" title="Initializes threads, like dbus_threads_init_default().">dbus_threads_init</a> (<span class="keyword">const</span> <a class="code" href="structDBusThreadFunctions.html" title="Functions that must be implemented to make the D-Bus library thread-aware.">DBusThreadFunctions</a> *functions)
<a name="l00392"></a>00392 {
<a name="l00393"></a>00393 <a class="code" href="group__DBusSysdeps.html#ga65d32daf6d876dd39b7410f3fa35b591" title="Lock a static mutex used to protect _dbus_threads_init_platform_specific().">_dbus_threads_lock_platform_specific</a> ();
<a name="l00394"></a>00394
<a name="l00395"></a>00395 <span class="keywordflow">if</span> (thread_init_generation == <a class="code" href="group__DBusMemoryInternals.html#ga7c224d82013e2bdc181c1d85dcb6f295" title="_dbus_current_generation is used to track each time that dbus_shutdown() is called, so we can reinit things after it's been called.">_dbus_current_generation</a>)
<a name="l00396"></a>00396 {
<a name="l00397"></a>00397 <a class="code" href="group__DBusSysdeps.html#ga99c22b80d17ef18fa0a11f3a2a415403" title="Undo _dbus_threads_lock_platform_specific().">_dbus_threads_unlock_platform_specific</a> ();
<a name="l00398"></a>00398 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00399"></a>00399 }
<a name="l00400"></a>00400
<a name="l00401"></a>00401 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdeps.html#gae7be34dbffb6458578e86c59a26d4fad" title="Initialize threads as in dbus_threads_init_default(), appropriately for the platform.">_dbus_threads_init_platform_specific</a>() ||
<a name="l00402"></a>00402 !init_global_locks ())
<a name="l00403"></a>00403 {
<a name="l00404"></a>00404 <a class="code" href="group__DBusSysdeps.html#ga99c22b80d17ef18fa0a11f3a2a415403" title="Undo _dbus_threads_lock_platform_specific().">_dbus_threads_unlock_platform_specific</a> ();
<a name="l00405"></a>00405 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00406"></a>00406 }
<a name="l00407"></a>00407
<a name="l00408"></a>00408 thread_init_generation = <a class="code" href="group__DBusMemoryInternals.html#ga7c224d82013e2bdc181c1d85dcb6f295" title="_dbus_current_generation is used to track each time that dbus_shutdown() is called, so we can reinit things after it's been called.">_dbus_current_generation</a>;
<a name="l00409"></a>00409
<a name="l00410"></a>00410 <a class="code" href="group__DBusSysdeps.html#ga99c22b80d17ef18fa0a11f3a2a415403" title="Undo _dbus_threads_lock_platform_specific().">_dbus_threads_unlock_platform_specific</a> ();
<a name="l00411"></a>00411 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00412"></a>00412 }
<a name="l00413"></a>00413
<a name="l00414"></a>00414
<a name="l00415"></a>00415
<a name="l00416"></a>00416 <span class="comment">/* Default thread implemenation */</span>
<a name="l00417"></a>00417
<a name="l00437"></a>00437 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00438"></a><a class="code" href="group__DBusThreads.html#ga33b6cf3b8f1e41bad5508f84758818a7">00438</a> <a class="code" href="group__DBusThreads.html#ga33b6cf3b8f1e41bad5508f84758818a7" title="Initializes threads.">dbus_threads_init_default</a> (<span class="keywordtype">void</span>)
<a name="l00439"></a>00439 {
<a name="l00440"></a>00440 <span class="keywordflow">return</span> <a class="code" href="group__DBusThreads.html#gac7b8a7001befc3eaa8c6b043151008dc" title="Initializes threads, like dbus_threads_init_default().">dbus_threads_init</a> (<a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00441"></a>00441 }
<a name="l00442"></a>00442
<a name="l00443"></a>00443
<a name="l00446"></a>00446 <span class="preprocessor">#ifdef DBUS_ENABLE_EMBEDDED_TESTS</span>
<a name="l00447"></a>00447 <span class="preprocessor"></span>
<a name="l00448"></a>00448 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00449"></a>00449 _dbus_threads_init_debug (<span class="keywordtype">void</span>)
<a name="l00450"></a>00450 {
<a name="l00451"></a>00451 <span class="keywordflow">return</span> <a class="code" href="group__DBusThreads.html#gac7b8a7001befc3eaa8c6b043151008dc" title="Initializes threads, like dbus_threads_init_default().">dbus_threads_init</a> (<a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00452"></a>00452 }
<a name="l00453"></a>00453
<a name="l00454"></a>00454 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_ENABLE_EMBEDDED_TESTS */</span>
</pre></div></div><!-- contents -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Mar 3 2016 17:50:32 for D-Bus by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>
</body>
</html>