|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /usr/share/devhelp/books/dbus/api/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>D-Bus: dbus-threads.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</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 id="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
</ul></div>
<h1>dbus-threads.c</h1><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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 "dbus-threads.h"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "dbus-internals.h"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "dbus-threads-internal.h"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "dbus-list.h"</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="keyword">static</span> <a class="code" href="structDBusThreadFunctions.html">DBusThreadFunctions</a> thread_functions =
<a name="l00029"></a>00029 {
<a name="l00030"></a>00030 0,
<a name="l00031"></a>00031 <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, NULL, NULL, NULL,
<a name="l00032"></a>00032 NULL, NULL, NULL, NULL, NULL,
<a name="l00033"></a>00033 NULL, NULL, NULL, NULL,
<a name="l00034"></a>00034
<a name="l00035"></a>00035 NULL, NULL, NULL, NULL
<a name="l00036"></a>00036 };
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="keyword">static</span> <span class="keywordtype">int</span> thread_init_generation = 0;
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="keyword">static</span> <a class="code" href="structDBusList.html">DBusList</a> *uninitialized_mutex_list = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00041"></a>00041 <span class="keyword">static</span> <a class="code" href="structDBusList.html">DBusList</a> *uninitialized_condvar_list = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00042"></a>00042
<a name="l00044"></a>00044 <span class="preprocessor">#define _DBUS_DUMMY_MUTEX ((DBusMutex*)0xABCDEF)</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span>
<a name="l00047"></a>00047 <span class="preprocessor">#define _DBUS_DUMMY_CONDVAR ((DBusCondVar*)0xABCDEF2)</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00067"></a>00067 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a>*
<a name="l00068"></a><a class="code" href="group__DBusThreadsInternals.html#ga68763a20debe2babcf441da8df6684c">00068</a> <a class="code" href="group__DBusThreadsInternals.html#ga68763a20debe2babcf441da8df6684c">_dbus_mutex_new</a> (<span class="keywordtype">void</span>)
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070 <span class="keywordflow">if</span> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#fd30fb78a3ca1064bc8c074a6a61361e">recursive_mutex_new</a>)
<a name="l00071"></a>00071 <span class="keywordflow">return</span> (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#fd30fb78a3ca1064bc8c074a6a61361e">recursive_mutex_new</a>) ();
<a name="l00072"></a>00072 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#342ba12a619162a5b228903076b46a44">mutex_new</a>)
<a name="l00073"></a>00073 <span class="keywordflow">return</span> (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#342ba12a619162a5b228903076b46a44">mutex_new</a>) ();
<a name="l00074"></a>00074 <span class="keywordflow">else</span>
<a name="l00075"></a>00075 <span class="keywordflow">return</span> _DBUS_DUMMY_MUTEX;
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077
<a name="l00087"></a>00087 <span class="keywordtype">void</span>
<a name="l00088"></a><a class="code" href="group__DBusThreadsInternals.html#g5b22688470ddee6e7b9c9b6eb751fa2e">00088</a> <a class="code" href="group__DBusThreadsInternals.html#g5b22688470ddee6e7b9c9b6eb751fa2e">_dbus_mutex_new_at_location</a> (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> **location_p)
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (location_p != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00091"></a>00091
<a name="l00092"></a>00092 *location_p = <a class="code" href="group__DBusThreadsInternals.html#ga68763a20debe2babcf441da8df6684c">_dbus_mutex_new</a>();
<a name="l00093"></a>00093
<a name="l00094"></a>00094 <span class="keywordflow">if</span> (thread_init_generation != <a class="code" href="group__DBusMemoryInternals.html#g7c224d82013e2bdc181c1d85dcb6f295">_dbus_current_generation</a> && *location_p)
<a name="l00095"></a>00095 {
<a name="l00096"></a>00096 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusList.html#gd99045e79db46159babe69718f343053">_dbus_list_append</a> (&uninitialized_mutex_list, location_p))
<a name="l00097"></a>00097 {
<a name="l00098"></a>00098 <a class="code" href="group__DBusThreadsInternals.html#gf9370643f45e9491d98a6819b422af5c">_dbus_mutex_free</a> (*location_p);
<a name="l00099"></a>00099 *location_p = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102 }
<a name="l00103"></a>00103
<a name="l00108"></a>00108 <span class="keywordtype">void</span>
<a name="l00109"></a><a class="code" href="group__DBusThreadsInternals.html#gf9370643f45e9491d98a6819b422af5c">00109</a> <a class="code" href="group__DBusThreadsInternals.html#gf9370643f45e9491d98a6819b422af5c">_dbus_mutex_free</a> (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex)
<a name="l00110"></a>00110 {
<a name="l00111"></a>00111 <span class="keywordflow">if</span> (mutex)
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113 <span class="keywordflow">if</span> (mutex && thread_functions.<a class="code" href="structDBusThreadFunctions.html#8be6d85b7f162352efa5bb4a5663f44f">recursive_mutex_free</a>)
<a name="l00114"></a>00114 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#8be6d85b7f162352efa5bb4a5663f44f">recursive_mutex_free</a>) (mutex);
<a name="l00115"></a>00115 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mutex && thread_functions.<a class="code" href="structDBusThreadFunctions.html#01107266a74895f13af9962af6ad07dd">mutex_free</a>)
<a name="l00116"></a>00116 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#01107266a74895f13af9962af6ad07dd">mutex_free</a>) (mutex);
<a name="l00117"></a>00117 }
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119
<a name="l00125"></a>00125 <span class="keywordtype">void</span>
<a name="l00126"></a><a class="code" href="group__DBusThreadsInternals.html#gfd7f94bf0c265660749ffa690e76248a">00126</a> <a class="code" href="group__DBusThreadsInternals.html#gfd7f94bf0c265660749ffa690e76248a">_dbus_mutex_free_at_location</a> (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> **location_p)
<a name="l00127"></a>00127 {
<a name="l00128"></a>00128 <span class="keywordflow">if</span> (location_p)
<a name="l00129"></a>00129 {
<a name="l00130"></a>00130 <span class="keywordflow">if</span> (thread_init_generation != <a class="code" href="group__DBusMemoryInternals.html#g7c224d82013e2bdc181c1d85dcb6f295">_dbus_current_generation</a>)
<a name="l00131"></a>00131 <a class="code" href="group__DBusList.html#g202e6ac8ad3e4a9d4413e0248ffcf3e3">_dbus_list_remove</a> (&uninitialized_mutex_list, location_p);
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <a class="code" href="group__DBusThreadsInternals.html#gf9370643f45e9491d98a6819b422af5c">_dbus_mutex_free</a> (*location_p);
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135 }
<a name="l00136"></a>00136
<a name="l00142"></a>00142 <span class="keywordtype">void</span>
<a name="l00143"></a><a class="code" href="group__DBusThreadsInternals.html#ge6eafe138e9c317bfb25971d1d8bef2d">00143</a> <a class="code" href="group__DBusThreadsInternals.html#ge6eafe138e9c317bfb25971d1d8bef2d">_dbus_mutex_lock</a> (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex)
<a name="l00144"></a>00144 {
<a name="l00145"></a>00145 <span class="keywordflow">if</span> (mutex)
<a name="l00146"></a>00146 {
<a name="l00147"></a>00147 <span class="keywordflow">if</span> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#e99179276be65fe4f701de307882dac5">recursive_mutex_lock</a>)
<a name="l00148"></a>00148 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#e99179276be65fe4f701de307882dac5">recursive_mutex_lock</a>) (mutex);
<a name="l00149"></a>00149 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#1cc9d20f2ad0296e932951470063f8d0">mutex_lock</a>)
<a name="l00150"></a>00150 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#1cc9d20f2ad0296e932951470063f8d0">mutex_lock</a>) (mutex);
<a name="l00151"></a>00151 }
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153
<a name="l00159"></a>00159 <span class="keywordtype">void</span>
<a name="l00160"></a><a class="code" href="group__DBusThreadsInternals.html#g94dcc555488e5d677f10bd3898d61c00">00160</a> <a class="code" href="group__DBusThreadsInternals.html#g94dcc555488e5d677f10bd3898d61c00">_dbus_mutex_unlock</a> (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex)
<a name="l00161"></a>00161 {
<a name="l00162"></a>00162 <span class="keywordflow">if</span> (mutex)
<a name="l00163"></a>00163 {
<a name="l00164"></a>00164 <span class="keywordflow">if</span> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#0bdb8cd9b263bcde5a0548b16ccd0702">recursive_mutex_unlock</a>)
<a name="l00165"></a>00165 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#0bdb8cd9b263bcde5a0548b16ccd0702">recursive_mutex_unlock</a>) (mutex);
<a name="l00166"></a>00166 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#334d478ec305b04f526537c131cd8e8a">mutex_unlock</a>)
<a name="l00167"></a>00167 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#334d478ec305b04f526537c131cd8e8a">mutex_unlock</a>) (mutex);
<a name="l00168"></a>00168 }
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170
<a name="l00179"></a>00179 <a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *
<a name="l00180"></a><a class="code" href="group__DBusThreadsInternals.html#g454b138bcbd419d38b3da6b707e46998">00180</a> <a class="code" href="group__DBusThreadsInternals.html#g454b138bcbd419d38b3da6b707e46998">_dbus_condvar_new</a> (<span class="keywordtype">void</span>)
<a name="l00181"></a>00181 {
<a name="l00182"></a>00182 <span class="keywordflow">if</span> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#1796b617165734984bc40d38f9600d78">condvar_new</a>)
<a name="l00183"></a>00183 <span class="keywordflow">return</span> (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#1796b617165734984bc40d38f9600d78">condvar_new</a>) ();
<a name="l00184"></a>00184 <span class="keywordflow">else</span>
<a name="l00185"></a>00185 <span class="keywordflow">return</span> _DBUS_DUMMY_CONDVAR;
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187
<a name="l00188"></a>00188
<a name="l00199"></a>00199 <span class="keywordtype">void</span>
<a name="l00200"></a><a class="code" href="group__DBusThreadsInternals.html#g859c5830e3c212323c1d6dafee3858a1">00200</a> <a class="code" href="group__DBusThreadsInternals.html#g859c5830e3c212323c1d6dafee3858a1">_dbus_condvar_new_at_location</a> (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> **location_p)
<a name="l00201"></a>00201 {
<a name="l00202"></a>00202 *location_p = <a class="code" href="group__DBusThreadsInternals.html#g454b138bcbd419d38b3da6b707e46998">_dbus_condvar_new</a>();
<a name="l00203"></a>00203
<a name="l00204"></a>00204 <span class="keywordflow">if</span> (thread_init_generation != <a class="code" href="group__DBusMemoryInternals.html#g7c224d82013e2bdc181c1d85dcb6f295">_dbus_current_generation</a> && *location_p)
<a name="l00205"></a>00205 {
<a name="l00206"></a>00206 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusList.html#gd99045e79db46159babe69718f343053">_dbus_list_append</a> (&uninitialized_condvar_list, location_p))
<a name="l00207"></a>00207 {
<a name="l00208"></a>00208 <a class="code" href="group__DBusThreadsInternals.html#gff04b7377b6ab0cc22fee6a2811dde84">_dbus_condvar_free</a> (*location_p);
<a name="l00209"></a>00209 *location_p = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211 }
<a name="l00212"></a>00212 }
<a name="l00213"></a>00213
<a name="l00214"></a>00214
<a name="l00219"></a>00219 <span class="keywordtype">void</span>
<a name="l00220"></a><a class="code" href="group__DBusThreadsInternals.html#gff04b7377b6ab0cc22fee6a2811dde84">00220</a> <a class="code" href="group__DBusThreadsInternals.html#gff04b7377b6ab0cc22fee6a2811dde84">_dbus_condvar_free</a> (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond)
<a name="l00221"></a>00221 {
<a name="l00222"></a>00222 <span class="keywordflow">if</span> (cond && thread_functions.<a class="code" href="structDBusThreadFunctions.html#d302412c382190eddc05736f24d8855c">condvar_free</a>)
<a name="l00223"></a>00223 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#d302412c382190eddc05736f24d8855c">condvar_free</a>) (cond);
<a name="l00224"></a>00224 }
<a name="l00225"></a>00225
<a name="l00231"></a>00231 <span class="keywordtype">void</span>
<a name="l00232"></a><a class="code" href="group__DBusThreadsInternals.html#g29444a34b569fca22fac48067832aacd">00232</a> <a class="code" href="group__DBusThreadsInternals.html#g29444a34b569fca22fac48067832aacd">_dbus_condvar_free_at_location</a> (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> **location_p)
<a name="l00233"></a>00233 {
<a name="l00234"></a>00234 <span class="keywordflow">if</span> (location_p)
<a name="l00235"></a>00235 {
<a name="l00236"></a>00236 <span class="keywordflow">if</span> (thread_init_generation != <a class="code" href="group__DBusMemoryInternals.html#g7c224d82013e2bdc181c1d85dcb6f295">_dbus_current_generation</a>)
<a name="l00237"></a>00237 <a class="code" href="group__DBusList.html#g202e6ac8ad3e4a9d4413e0248ffcf3e3">_dbus_list_remove</a> (&uninitialized_condvar_list, location_p);
<a name="l00238"></a>00238
<a name="l00239"></a>00239 <a class="code" href="group__DBusThreadsInternals.html#gff04b7377b6ab0cc22fee6a2811dde84">_dbus_condvar_free</a> (*location_p);
<a name="l00240"></a>00240 }
<a name="l00241"></a>00241 }
<a name="l00242"></a>00242
<a name="l00249"></a>00249 <span class="keywordtype">void</span>
<a name="l00250"></a><a class="code" href="group__DBusThreadsInternals.html#g393c0cfdec998dc5abe49480ac21ea51">00250</a> <a class="code" href="group__DBusThreadsInternals.html#g393c0cfdec998dc5abe49480ac21ea51">_dbus_condvar_wait</a> (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond,
<a name="l00251"></a>00251 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex)
<a name="l00252"></a>00252 {
<a name="l00253"></a>00253 <span class="keywordflow">if</span> (cond && mutex && thread_functions.<a class="code" href="structDBusThreadFunctions.html#e4cb6e9fe7c0813213561150721f349c">condvar_wait</a>)
<a name="l00254"></a>00254 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#e4cb6e9fe7c0813213561150721f349c">condvar_wait</a>) (cond, mutex);
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256
<a name="l00268"></a>00268 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00269"></a><a class="code" href="group__DBusThreadsInternals.html#gac7b2117e5479ca6858734b59cfb9259">00269</a> <a class="code" href="group__DBusThreadsInternals.html#gac7b2117e5479ca6858734b59cfb9259">_dbus_condvar_wait_timeout</a> (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond,
<a name="l00270"></a>00270 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex,
<a name="l00271"></a>00271 <span class="keywordtype">int</span> timeout_milliseconds)
<a name="l00272"></a>00272 {
<a name="l00273"></a>00273 <span class="keywordflow">if</span> (cond && mutex && thread_functions.<a class="code" href="structDBusThreadFunctions.html#e4cb6e9fe7c0813213561150721f349c">condvar_wait</a>)
<a name="l00274"></a>00274 <span class="keywordflow">return</span> (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#5e049c7bdf4d83a85ebce31d838d4218">condvar_wait_timeout</a>) (cond, mutex, timeout_milliseconds);
<a name="l00275"></a>00275 <span class="keywordflow">else</span>
<a name="l00276"></a>00276 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278
<a name="l00284"></a>00284 <span class="keywordtype">void</span>
<a name="l00285"></a><a class="code" href="group__DBusThreadsInternals.html#g8af2fd84773022e7e7ce1f21f0126203">00285</a> <a class="code" href="group__DBusThreadsInternals.html#g8af2fd84773022e7e7ce1f21f0126203">_dbus_condvar_wake_one</a> (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond)
<a name="l00286"></a>00286 {
<a name="l00287"></a>00287 <span class="keywordflow">if</span> (cond && thread_functions.<a class="code" href="structDBusThreadFunctions.html#3f1301eacf666381ec6c39100e6787e1">condvar_wake_one</a>)
<a name="l00288"></a>00288 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#3f1301eacf666381ec6c39100e6787e1">condvar_wake_one</a>) (cond);
<a name="l00289"></a>00289 }
<a name="l00290"></a>00290
<a name="l00296"></a>00296 <span class="keywordtype">void</span>
<a name="l00297"></a><a class="code" href="group__DBusThreadsInternals.html#g1a9ce112b6bc72feccd34f9251744e76">00297</a> <a class="code" href="group__DBusThreadsInternals.html#g1a9ce112b6bc72feccd34f9251744e76">_dbus_condvar_wake_all</a> (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond)
<a name="l00298"></a>00298 {
<a name="l00299"></a>00299 <span class="keywordflow">if</span> (cond && thread_functions.<a class="code" href="structDBusThreadFunctions.html#128295c0019a401163d04ea0e291b36c">condvar_wake_all</a>)
<a name="l00300"></a>00300 (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#128295c0019a401163d04ea0e291b36c">condvar_wake_all</a>) (cond);
<a name="l00301"></a>00301 }
<a name="l00302"></a>00302
<a name="l00303"></a>00303 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00304"></a>00304 shutdown_global_locks (<span class="keywordtype">void</span> *data)
<a name="l00305"></a>00305 {
<a name="l00306"></a>00306 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> ***locks = data;
<a name="l00307"></a>00307 <span class="keywordtype">int</span> i;
<a name="l00308"></a>00308
<a name="l00309"></a>00309 i = 0;
<a name="l00310"></a>00310 <span class="keywordflow">while</span> (i < _DBUS_N_GLOBAL_LOCKS)
<a name="l00311"></a>00311 {
<a name="l00312"></a>00312 <a class="code" href="group__DBusThreadsInternals.html#gf9370643f45e9491d98a6819b422af5c">_dbus_mutex_free</a> (*(locks[i]));
<a name="l00313"></a>00313 *(locks[i]) = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00314"></a>00314 ++i;
<a name="l00315"></a>00315 }
<a name="l00316"></a>00316
<a name="l00317"></a>00317 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (locks);
<a name="l00318"></a>00318 }
<a name="l00319"></a>00319
<a name="l00320"></a>00320 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00321"></a>00321 shutdown_uninitialized_locks (<span class="keywordtype">void</span> *data)
<a name="l00322"></a>00322 {
<a name="l00323"></a>00323 <a class="code" href="group__DBusList.html#ga36d13444a050a923941c53650b72f9d">_dbus_list_clear</a> (&uninitialized_mutex_list);
<a name="l00324"></a>00324 <a class="code" href="group__DBusList.html#ga36d13444a050a923941c53650b72f9d">_dbus_list_clear</a> (&uninitialized_condvar_list);
<a name="l00325"></a>00325 }
<a name="l00326"></a>00326
<a name="l00327"></a>00327 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00328"></a>00328 init_uninitialized_locks (<span class="keywordtype">void</span>)
<a name="l00329"></a>00329 {
<a name="l00330"></a>00330 <a class="code" href="structDBusList.html">DBusList</a> *link;
<a name="l00331"></a>00331
<a name="l00332"></a>00332 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (thread_init_generation != <a class="code" href="group__DBusMemoryInternals.html#g7c224d82013e2bdc181c1d85dcb6f295">_dbus_current_generation</a>);
<a name="l00333"></a>00333
<a name="l00334"></a>00334 link = uninitialized_mutex_list;
<a name="l00335"></a>00335 <span class="keywordflow">while</span> (link != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00336"></a>00336 {
<a name="l00337"></a>00337 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> **mp;
<a name="l00338"></a>00338
<a name="l00339"></a>00339 mp = (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> **)link-><a class="code" href="structDBusList.html#29ab457bcf9092252bb0c4282c727055">data</a>;
<a name="l00340"></a>00340 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (*mp == _DBUS_DUMMY_MUTEX);
<a name="l00341"></a>00341
<a name="l00342"></a>00342 *mp = <a class="code" href="group__DBusThreadsInternals.html#ga68763a20debe2babcf441da8df6684c">_dbus_mutex_new</a> ();
<a name="l00343"></a>00343 <span class="keywordflow">if</span> (*mp == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00344"></a>00344 <span class="keywordflow">goto</span> fail_mutex;
<a name="l00345"></a>00345
<a name="l00346"></a>00346 link = <a class="code" href="group__DBusList.html#gede4ace46d5ee497d75074bfec4490a2">_dbus_list_get_next_link</a> (&uninitialized_mutex_list, link);
<a name="l00347"></a>00347 }
<a name="l00348"></a>00348
<a name="l00349"></a>00349 link = uninitialized_condvar_list;
<a name="l00350"></a>00350 <span class="keywordflow">while</span> (link != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00351"></a>00351 {
<a name="l00352"></a>00352 <a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> **cp;
<a name="l00353"></a>00353
<a name="l00354"></a>00354 cp = (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> **)link-><a class="code" href="structDBusList.html#29ab457bcf9092252bb0c4282c727055">data</a>;
<a name="l00355"></a>00355 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (*cp == _DBUS_DUMMY_CONDVAR);
<a name="l00356"></a>00356
<a name="l00357"></a>00357 *cp = <a class="code" href="group__DBusThreadsInternals.html#g454b138bcbd419d38b3da6b707e46998">_dbus_condvar_new</a> ();
<a name="l00358"></a>00358 <span class="keywordflow">if</span> (*cp == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00359"></a>00359 <span class="keywordflow">goto</span> fail_condvar;
<a name="l00360"></a>00360
<a name="l00361"></a>00361 link = <a class="code" href="group__DBusList.html#gede4ace46d5ee497d75074bfec4490a2">_dbus_list_get_next_link</a> (&uninitialized_condvar_list, link);
<a name="l00362"></a>00362 }
<a name="l00363"></a>00363
<a name="l00364"></a>00364 <a class="code" href="group__DBusList.html#ga36d13444a050a923941c53650b72f9d">_dbus_list_clear</a> (&uninitialized_mutex_list);
<a name="l00365"></a>00365 <a class="code" href="group__DBusList.html#ga36d13444a050a923941c53650b72f9d">_dbus_list_clear</a> (&uninitialized_condvar_list);
<a name="l00366"></a>00366
<a name="l00367"></a>00367 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusMemoryInternals.html#g8dc6d5dd0a0e7901ab793da7403ee734">_dbus_register_shutdown_func</a> (shutdown_uninitialized_locks,
<a name="l00368"></a>00368 <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>))
<a name="l00369"></a>00369 <span class="keywordflow">goto</span> fail_condvar;
<a name="l00370"></a>00370
<a name="l00371"></a>00371 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00372"></a>00372
<a name="l00373"></a>00373 fail_condvar:
<a name="l00374"></a>00374 link = uninitialized_condvar_list;
<a name="l00375"></a>00375 <span class="keywordflow">while</span> (link != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00376"></a>00376 {
<a name="l00377"></a>00377 <a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> **cp;
<a name="l00378"></a>00378
<a name="l00379"></a>00379 cp = (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> **)link-><a class="code" href="structDBusList.html#29ab457bcf9092252bb0c4282c727055">data</a>;
<a name="l00380"></a>00380
<a name="l00381"></a>00381 if (*cp != _DBUS_DUMMY_CONDVAR)
<a name="l00382"></a>00382 <a class="code" href="group__DBusThreadsInternals.html#gff04b7377b6ab0cc22fee6a2811dde84">_dbus_condvar_free</a> (*cp);
<a name="l00383"></a>00383 <span class="keywordflow">else</span>
<a name="l00384"></a>00384 <span class="keywordflow">break</span>;
<a name="l00385"></a>00385
<a name="l00386"></a>00386 *cp = _DBUS_DUMMY_CONDVAR;
<a name="l00387"></a>00387
<a name="l00388"></a>00388 link = <a class="code" href="group__DBusList.html#gede4ace46d5ee497d75074bfec4490a2">_dbus_list_get_next_link</a> (&uninitialized_condvar_list, link);
<a name="l00389"></a>00389 }
<a name="l00390"></a>00390
<a name="l00391"></a>00391 fail_mutex:
<a name="l00392"></a>00392 link = uninitialized_mutex_list;
<a name="l00393"></a>00393 <span class="keywordflow">while</span> (link != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00394"></a>00394 {
<a name="l00395"></a>00395 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> **mp;
<a name="l00396"></a>00396
<a name="l00397"></a>00397 mp = (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> **)link-><a class="code" href="structDBusList.html#29ab457bcf9092252bb0c4282c727055">data</a>;
<a name="l00398"></a>00398
<a name="l00399"></a>00399 if (*mp != _DBUS_DUMMY_MUTEX)
<a name="l00400"></a>00400 <a class="code" href="group__DBusThreadsInternals.html#gf9370643f45e9491d98a6819b422af5c">_dbus_mutex_free</a> (*mp);
<a name="l00401"></a>00401 <span class="keywordflow">else</span>
<a name="l00402"></a>00402 <span class="keywordflow">break</span>;
<a name="l00403"></a>00403
<a name="l00404"></a>00404 *mp = _DBUS_DUMMY_MUTEX;
<a name="l00405"></a>00405
<a name="l00406"></a>00406 link = <a class="code" href="group__DBusList.html#gede4ace46d5ee497d75074bfec4490a2">_dbus_list_get_next_link</a> (&uninitialized_mutex_list, link);
<a name="l00407"></a>00407 }
<a name="l00408"></a>00408
<a name="l00409"></a>00409 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00410"></a>00410 }
<a name="l00411"></a>00411
<a name="l00412"></a>00412 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00413"></a>00413 init_locks (<span class="keywordtype">void</span>)
<a name="l00414"></a>00414 {
<a name="l00415"></a>00415 <span class="keywordtype">int</span> i;
<a name="l00416"></a>00416 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> ***dynamic_global_locks;
<a name="l00417"></a>00417
<a name="l00418"></a>00418 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> **global_locks[] = {
<a name="l00419"></a>00419 <span class="preprocessor">#define LOCK_ADDR(name) (& _dbus_lock_##name)</span>
<a name="l00420"></a>00420 <span class="preprocessor"></span> LOCK_ADDR (win_fds),
<a name="l00421"></a>00421 LOCK_ADDR (sid_atom_cache),
<a name="l00422"></a>00422 LOCK_ADDR (list),
<a name="l00423"></a>00423 LOCK_ADDR (connection_slots),
<a name="l00424"></a>00424 LOCK_ADDR (pending_call_slots),
<a name="l00425"></a>00425 LOCK_ADDR (server_slots),
<a name="l00426"></a>00426 LOCK_ADDR (message_slots),
<a name="l00427"></a>00427 LOCK_ADDR (atomic),
<a name="l00428"></a>00428 LOCK_ADDR (bus),
<a name="l00429"></a>00429 LOCK_ADDR (bus_datas),
<a name="l00430"></a>00430 LOCK_ADDR (shutdown_funcs),
<a name="l00431"></a>00431 LOCK_ADDR (system_users),
<a name="l00432"></a>00432 LOCK_ADDR (message_cache),
<a name="l00433"></a>00433 LOCK_ADDR (shared_connections),
<a name="l00434"></a>00434 LOCK_ADDR (machine_uuid)
<a name="l00435"></a>00435 <span class="preprocessor">#undef LOCK_ADDR</span>
<a name="l00436"></a>00436 <span class="preprocessor"></span> };
<a name="l00437"></a>00437
<a name="l00438"></a>00438 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<a class="code" href="group__DBusInternalsUtils.html#gc153abad46f4eb80999a2b340d29d1f0">_DBUS_N_ELEMENTS</a> (global_locks) ==
<a name="l00439"></a>00439 _DBUS_N_GLOBAL_LOCKS);
<a name="l00440"></a>00440
<a name="l00441"></a>00441 i = 0;
<a name="l00442"></a>00442
<a name="l00443"></a>00443 dynamic_global_locks = <a class="code" href="group__DBusMemory.html#g54ccb556e7964112a825a7f46c156ca0">dbus_new</a> (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a>**, _DBUS_N_GLOBAL_LOCKS);
<a name="l00444"></a>00444 <span class="keywordflow">if</span> (dynamic_global_locks == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00445"></a>00445 <span class="keywordflow">goto</span> failed;
<a name="l00446"></a>00446
<a name="l00447"></a>00447 <span class="keywordflow">while</span> (i < <a class="code" href="group__DBusInternalsUtils.html#gc153abad46f4eb80999a2b340d29d1f0">_DBUS_N_ELEMENTS</a> (global_locks))
<a name="l00448"></a>00448 {
<a name="l00449"></a>00449 *global_locks[i] = <a class="code" href="group__DBusThreadsInternals.html#ga68763a20debe2babcf441da8df6684c">_dbus_mutex_new</a> ();
<a name="l00450"></a>00450
<a name="l00451"></a>00451 <span class="keywordflow">if</span> (*global_locks[i] == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00452"></a>00452 <span class="keywordflow">goto</span> failed;
<a name="l00453"></a>00453
<a name="l00454"></a>00454 dynamic_global_locks[i] = global_locks[i];
<a name="l00455"></a>00455
<a name="l00456"></a>00456 ++i;
<a name="l00457"></a>00457 }
<a name="l00458"></a>00458
<a name="l00459"></a>00459 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusMemoryInternals.html#g8dc6d5dd0a0e7901ab793da7403ee734">_dbus_register_shutdown_func</a> (shutdown_global_locks,
<a name="l00460"></a>00460 dynamic_global_locks))
<a name="l00461"></a>00461 <span class="keywordflow">goto</span> failed;
<a name="l00462"></a>00462
<a name="l00463"></a>00463 <span class="keywordflow">if</span> (!init_uninitialized_locks ())
<a name="l00464"></a>00464 <span class="keywordflow">goto</span> failed;
<a name="l00465"></a>00465
<a name="l00466"></a>00466 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00467"></a>00467
<a name="l00468"></a>00468 failed:
<a name="l00469"></a>00469 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (dynamic_global_locks);
<a name="l00470"></a>00470
<a name="l00471"></a>00471 <span class="keywordflow">for</span> (i = i - 1; i >= 0; i--)
<a name="l00472"></a>00472 {
<a name="l00473"></a>00473 <a class="code" href="group__DBusThreadsInternals.html#gf9370643f45e9491d98a6819b422af5c">_dbus_mutex_free</a> (*global_locks[i]);
<a name="l00474"></a>00474 *global_locks[i] = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00475"></a>00475 }
<a name="l00476"></a>00476 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00477"></a>00477 }
<a name="l00478"></a>00478 <span class="comment">/* end of internals */</span>
<a name="l00480"></a>00480
<a name="l00544"></a>00544 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00545"></a><a class="code" href="group__DBusThreads.html#ga9a4ed445c77af3afa0dbdbb9d85afd4">00545</a> <a class="code" href="group__DBusThreads.html#ga9a4ed445c77af3afa0dbdbb9d85afd4">dbus_threads_init</a> (<span class="keyword">const</span> <a class="code" href="structDBusThreadFunctions.html">DBusThreadFunctions</a> *functions)
<a name="l00546"></a>00546 {
<a name="l00547"></a>00547 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> mutex_set;
<a name="l00548"></a>00548 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> recursive_mutex_set;
<a name="l00549"></a>00549
<a name="l00550"></a>00550 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00551"></a>00551
<a name="l00552"></a>00552 <span class="comment">/* these base functions are required. Future additions to</span>
<a name="l00553"></a>00553 <span class="comment"> * DBusThreadFunctions may be optional.</span>
<a name="l00554"></a>00554 <span class="comment"> */</span>
<a name="l00555"></a>00555 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK);
<a name="l00556"></a>00556 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK);
<a name="l00557"></a>00557 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK);
<a name="l00558"></a>00558 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK);
<a name="l00559"></a>00559 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK);
<a name="l00560"></a>00560 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK);
<a name="l00561"></a>00561 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#1796b617165734984bc40d38f9600d78">condvar_new</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00562"></a>00562 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#d302412c382190eddc05736f24d8855c">condvar_free</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00563"></a>00563 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#e4cb6e9fe7c0813213561150721f349c">condvar_wait</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00564"></a>00564 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#5e049c7bdf4d83a85ebce31d838d4218">condvar_wait_timeout</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00565"></a>00565 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#3f1301eacf666381ec6c39100e6787e1">condvar_wake_one</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00566"></a>00566 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (functions-><a class="code" href="structDBusThreadFunctions.html#128295c0019a401163d04ea0e291b36c">condvar_wake_all</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00567"></a>00567
<a name="l00568"></a>00568 <span class="comment">/* Either the mutex function set or recursive mutex set needs </span>
<a name="l00569"></a>00569 <span class="comment"> * to be available but not both</span>
<a name="l00570"></a>00570 <span class="comment"> */</span>
<a name="l00571"></a>00571 mutex_set = (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK) &&
<a name="l00572"></a>00572 (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK) &&
<a name="l00573"></a>00573 (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK) &&
<a name="l00574"></a>00574 (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK) &&
<a name="l00575"></a>00575 functions-><a class="code" href="structDBusThreadFunctions.html#342ba12a619162a5b228903076b46a44">mutex_new</a> &&
<a name="l00576"></a>00576 functions-><a class="code" href="structDBusThreadFunctions.html#01107266a74895f13af9962af6ad07dd">mutex_free</a> &&
<a name="l00577"></a>00577 functions-><a class="code" href="structDBusThreadFunctions.html#1cc9d20f2ad0296e932951470063f8d0">mutex_lock</a> &&
<a name="l00578"></a>00578 functions-><a class="code" href="structDBusThreadFunctions.html#334d478ec305b04f526537c131cd8e8a">mutex_unlock</a>;
<a name="l00579"></a>00579
<a name="l00580"></a>00580 recursive_mutex_set =
<a name="l00581"></a>00581 (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK) &&
<a name="l00582"></a>00582 (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK) &&
<a name="l00583"></a>00583 (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK) &&
<a name="l00584"></a>00584 (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK) &&
<a name="l00585"></a>00585 functions-><a class="code" href="structDBusThreadFunctions.html#fd30fb78a3ca1064bc8c074a6a61361e">recursive_mutex_new</a> &&
<a name="l00586"></a>00586 functions-><a class="code" href="structDBusThreadFunctions.html#8be6d85b7f162352efa5bb4a5663f44f">recursive_mutex_free</a> &&
<a name="l00587"></a>00587 functions-><a class="code" href="structDBusThreadFunctions.html#e99179276be65fe4f701de307882dac5">recursive_mutex_lock</a> &&
<a name="l00588"></a>00588 functions-><a class="code" href="structDBusThreadFunctions.html#0bdb8cd9b263bcde5a0548b16ccd0702">recursive_mutex_unlock</a>;
<a name="l00589"></a>00589
<a name="l00590"></a>00590 <span class="keywordflow">if</span> (!(mutex_set || recursive_mutex_set))
<a name="l00591"></a>00591 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"Either the nonrecusrive or recursive mutex "</span>
<a name="l00592"></a>00592 <span class="stringliteral">"functions sets should be passed into "</span>
<a name="l00593"></a>00593 <span class="stringliteral">"dbus_threads_init. Neither sets were passed."</span>);
<a name="l00594"></a>00594
<a name="l00595"></a>00595 <span class="keywordflow">if</span> (mutex_set && recursive_mutex_set)
<a name="l00596"></a>00596 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"Either the nonrecusrive or recursive mutex "</span>
<a name="l00597"></a>00597 <span class="stringliteral">"functions sets should be passed into "</span>
<a name="l00598"></a>00598 <span class="stringliteral">"dbus_threads_init. Both sets were passed. "</span>
<a name="l00599"></a>00599 <span class="stringliteral">"You most likely just want to set the recursive "</span>
<a name="l00600"></a>00600 <span class="stringliteral">"mutex functions to avoid deadlocks in D-Bus."</span>);
<a name="l00601"></a>00601
<a name="l00602"></a>00602 <span class="comment">/* Check that all bits in the mask actually are valid mask bits.</span>
<a name="l00603"></a>00603 <span class="comment"> * ensures people won't write code that breaks when we add</span>
<a name="l00604"></a>00604 <span class="comment"> * new bits.</span>
<a name="l00605"></a>00605 <span class="comment"> */</span>
<a name="l00606"></a>00606 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> ((functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & ~DBUS_THREAD_FUNCTIONS_ALL_MASK) == 0);
<a name="l00607"></a>00607
<a name="l00608"></a>00608 <span class="keywordflow">if</span> (thread_init_generation != <a class="code" href="group__DBusMemoryInternals.html#g7c224d82013e2bdc181c1d85dcb6f295">_dbus_current_generation</a>)
<a name="l00609"></a>00609 thread_functions.<a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> = 0; <span class="comment">/* allow re-init in new generation */</span>
<a name="l00610"></a>00610
<a name="l00611"></a>00611 <span class="comment">/* Silently allow multiple init</span>
<a name="l00612"></a>00612 <span class="comment"> * First init wins and D-Bus will always use its threading system </span>
<a name="l00613"></a>00613 <span class="comment"> */</span>
<a name="l00614"></a>00614 <span class="keywordflow">if</span> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> != 0)
<a name="l00615"></a>00615 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00616"></a>00616
<a name="l00617"></a>00617 thread_functions.<a class="code" href="structDBusThreadFunctions.html#342ba12a619162a5b228903076b46a44">mutex_new</a> = functions-><a class="code" href="structDBusThreadFunctions.html#342ba12a619162a5b228903076b46a44">mutex_new</a>;
<a name="l00618"></a>00618 thread_functions.<a class="code" href="structDBusThreadFunctions.html#01107266a74895f13af9962af6ad07dd">mutex_free</a> = functions-><a class="code" href="structDBusThreadFunctions.html#01107266a74895f13af9962af6ad07dd">mutex_free</a>;
<a name="l00619"></a>00619 thread_functions.<a class="code" href="structDBusThreadFunctions.html#1cc9d20f2ad0296e932951470063f8d0">mutex_lock</a> = functions-><a class="code" href="structDBusThreadFunctions.html#1cc9d20f2ad0296e932951470063f8d0">mutex_lock</a>;
<a name="l00620"></a>00620 thread_functions.<a class="code" href="structDBusThreadFunctions.html#334d478ec305b04f526537c131cd8e8a">mutex_unlock</a> = functions-><a class="code" href="structDBusThreadFunctions.html#334d478ec305b04f526537c131cd8e8a">mutex_unlock</a>;
<a name="l00621"></a>00621
<a name="l00622"></a>00622 thread_functions.<a class="code" href="structDBusThreadFunctions.html#1796b617165734984bc40d38f9600d78">condvar_new</a> = functions-><a class="code" href="structDBusThreadFunctions.html#1796b617165734984bc40d38f9600d78">condvar_new</a>;
<a name="l00623"></a>00623 thread_functions.<a class="code" href="structDBusThreadFunctions.html#d302412c382190eddc05736f24d8855c">condvar_free</a> = functions-><a class="code" href="structDBusThreadFunctions.html#d302412c382190eddc05736f24d8855c">condvar_free</a>;
<a name="l00624"></a>00624 thread_functions.<a class="code" href="structDBusThreadFunctions.html#e4cb6e9fe7c0813213561150721f349c">condvar_wait</a> = functions-><a class="code" href="structDBusThreadFunctions.html#e4cb6e9fe7c0813213561150721f349c">condvar_wait</a>;
<a name="l00625"></a>00625 thread_functions.<a class="code" href="structDBusThreadFunctions.html#5e049c7bdf4d83a85ebce31d838d4218">condvar_wait_timeout</a> = functions-><a class="code" href="structDBusThreadFunctions.html#5e049c7bdf4d83a85ebce31d838d4218">condvar_wait_timeout</a>;
<a name="l00626"></a>00626 thread_functions.<a class="code" href="structDBusThreadFunctions.html#3f1301eacf666381ec6c39100e6787e1">condvar_wake_one</a> = functions-><a class="code" href="structDBusThreadFunctions.html#3f1301eacf666381ec6c39100e6787e1">condvar_wake_one</a>;
<a name="l00627"></a>00627 thread_functions.<a class="code" href="structDBusThreadFunctions.html#128295c0019a401163d04ea0e291b36c">condvar_wake_all</a> = functions-><a class="code" href="structDBusThreadFunctions.html#128295c0019a401163d04ea0e291b36c">condvar_wake_all</a>;
<a name="l00628"></a>00628
<a name="l00629"></a>00629 <span class="keywordflow">if</span> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK)
<a name="l00630"></a>00630 thread_functions.<a class="code" href="structDBusThreadFunctions.html#fd30fb78a3ca1064bc8c074a6a61361e">recursive_mutex_new</a> = functions-><a class="code" href="structDBusThreadFunctions.html#fd30fb78a3ca1064bc8c074a6a61361e">recursive_mutex_new</a>;
<a name="l00631"></a>00631
<a name="l00632"></a>00632 <span class="keywordflow">if</span> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK)
<a name="l00633"></a>00633 thread_functions.<a class="code" href="structDBusThreadFunctions.html#8be6d85b7f162352efa5bb4a5663f44f">recursive_mutex_free</a> = functions-><a class="code" href="structDBusThreadFunctions.html#8be6d85b7f162352efa5bb4a5663f44f">recursive_mutex_free</a>;
<a name="l00634"></a>00634
<a name="l00635"></a>00635 <span class="keywordflow">if</span> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK)
<a name="l00636"></a>00636 thread_functions.<a class="code" href="structDBusThreadFunctions.html#e99179276be65fe4f701de307882dac5">recursive_mutex_lock</a> = functions-><a class="code" href="structDBusThreadFunctions.html#e99179276be65fe4f701de307882dac5">recursive_mutex_lock</a>;
<a name="l00637"></a>00637
<a name="l00638"></a>00638 <span class="keywordflow">if</span> (functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> & DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK)
<a name="l00639"></a>00639 thread_functions.<a class="code" href="structDBusThreadFunctions.html#0bdb8cd9b263bcde5a0548b16ccd0702">recursive_mutex_unlock</a> = functions-><a class="code" href="structDBusThreadFunctions.html#0bdb8cd9b263bcde5a0548b16ccd0702">recursive_mutex_unlock</a>;
<a name="l00640"></a>00640
<a name="l00641"></a>00641 thread_functions.<a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a> = functions-><a class="code" href="structDBusThreadFunctions.html#8f1c2a3b3805e2c4034d7a341f7f82f1">mask</a>;
<a name="l00642"></a>00642
<a name="l00643"></a>00643 <span class="keywordflow">if</span> (!init_locks ())
<a name="l00644"></a>00644 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00645"></a>00645
<a name="l00646"></a>00646 thread_init_generation = <a class="code" href="group__DBusMemoryInternals.html#g7c224d82013e2bdc181c1d85dcb6f295">_dbus_current_generation</a>;
<a name="l00647"></a>00647
<a name="l00648"></a>00648 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00649"></a>00649 }
<a name="l00650"></a>00650
<a name="l00651"></a>00651
<a name="l00652"></a>00652
<a name="l00653"></a>00653 <span class="comment">/* Default thread implemenation */</span>
<a name="l00654"></a>00654
<a name="l00670"></a>00670 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00671"></a><a class="code" href="group__DBusThreads.html#gf508fbf3e39435491244b856183a1296">00671</a> <a class="code" href="group__DBusThreads.html#gf508fbf3e39435491244b856183a1296">dbus_threads_init_default</a> (<span class="keywordtype">void</span>)
<a name="l00672"></a>00672 {
<a name="l00673"></a>00673 <span class="keywordflow">return</span> <a class="code" href="group__DBusSysdeps.html#ge7be34dbffb6458578e86c59a26d4fad">_dbus_threads_init_platform_specific</a> ();
<a name="l00674"></a>00674 }
<a name="l00675"></a>00675
<a name="l00676"></a>00676
<a name="l00679"></a>00679 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l00680"></a>00680 <span class="preprocessor"></span>
<a name="l00681"></a>00681 <span class="keyword">typedef</span> <span class="keyword">struct </span>DBusFakeMutex DBusFakeMutex;
<a name="l00683"></a>00683 <span class="keyword">struct </span>DBusFakeMutex
<a name="l00684"></a>00684 {
<a name="l00685"></a>00685 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> locked;
<a name="l00686"></a>00686 };
<a name="l00687"></a>00687
<a name="l00688"></a>00688 <span class="keyword">static</span> <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> * dbus_fake_mutex_new (<span class="keywordtype">void</span>);
<a name="l00689"></a>00689 <span class="keyword">static</span> <span class="keywordtype">void</span> dbus_fake_mutex_free (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex);
<a name="l00690"></a>00690 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> dbus_fake_mutex_lock (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex);
<a name="l00691"></a>00691 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> dbus_fake_mutex_unlock (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex);
<a name="l00692"></a>00692 <span class="keyword">static</span> <a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a>* dbus_fake_condvar_new (<span class="keywordtype">void</span>);
<a name="l00693"></a>00693 <span class="keyword">static</span> <span class="keywordtype">void</span> dbus_fake_condvar_free (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond);
<a name="l00694"></a>00694 <span class="keyword">static</span> <span class="keywordtype">void</span> dbus_fake_condvar_wait (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond,
<a name="l00695"></a>00695 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex);
<a name="l00696"></a>00696 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> dbus_fake_condvar_wait_timeout (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond,
<a name="l00697"></a>00697 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex,
<a name="l00698"></a>00698 <span class="keywordtype">int</span> timeout_msec);
<a name="l00699"></a>00699 <span class="keyword">static</span> <span class="keywordtype">void</span> dbus_fake_condvar_wake_one (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond);
<a name="l00700"></a>00700 <span class="keyword">static</span> <span class="keywordtype">void</span> dbus_fake_condvar_wake_all (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond);
<a name="l00701"></a>00701
<a name="l00702"></a>00702
<a name="l00703"></a>00703 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusThreadFunctions.html">DBusThreadFunctions</a> fake_functions =
<a name="l00704"></a>00704 {
<a name="l00705"></a>00705 DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK |
<a name="l00706"></a>00706 DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK |
<a name="l00707"></a>00707 DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK |
<a name="l00708"></a>00708 DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK |
<a name="l00709"></a>00709 DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK |
<a name="l00710"></a>00710 DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK |
<a name="l00711"></a>00711 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK |
<a name="l00712"></a>00712 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK |
<a name="l00713"></a>00713 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK|
<a name="l00714"></a>00714 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK,
<a name="l00715"></a>00715 dbus_fake_mutex_new,
<a name="l00716"></a>00716 dbus_fake_mutex_free,
<a name="l00717"></a>00717 dbus_fake_mutex_lock,
<a name="l00718"></a>00718 dbus_fake_mutex_unlock,
<a name="l00719"></a>00719 dbus_fake_condvar_new,
<a name="l00720"></a>00720 dbus_fake_condvar_free,
<a name="l00721"></a>00721 dbus_fake_condvar_wait,
<a name="l00722"></a>00722 dbus_fake_condvar_wait_timeout,
<a name="l00723"></a>00723 dbus_fake_condvar_wake_one,
<a name="l00724"></a>00724 dbus_fake_condvar_wake_all
<a name="l00725"></a>00725 };
<a name="l00726"></a>00726
<a name="l00727"></a>00727 <span class="keyword">static</span> <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *
<a name="l00728"></a>00728 dbus_fake_mutex_new (<span class="keywordtype">void</span>)
<a name="l00729"></a>00729 {
<a name="l00730"></a>00730 DBusFakeMutex *mutex;
<a name="l00731"></a>00731
<a name="l00732"></a>00732 mutex = <a class="code" href="group__DBusMemory.html#gba9d823abda7f4cadbaf5177d3b8b793">dbus_new0</a> (DBusFakeMutex, 1);
<a name="l00733"></a>00733
<a name="l00734"></a>00734 <span class="keywordflow">return</span> (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *)mutex;
<a name="l00735"></a>00735 }
<a name="l00736"></a>00736
<a name="l00737"></a>00737 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00738"></a>00738 dbus_fake_mutex_free (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex)
<a name="l00739"></a>00739 {
<a name="l00740"></a>00740 DBusFakeMutex *fake = (DBusFakeMutex*) mutex;
<a name="l00741"></a>00741
<a name="l00742"></a>00742 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (!fake->locked);
<a name="l00743"></a>00743
<a name="l00744"></a>00744 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (fake);
<a name="l00745"></a>00745 }
<a name="l00746"></a>00746
<a name="l00747"></a>00747 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00748"></a>00748 dbus_fake_mutex_lock (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex)
<a name="l00749"></a>00749 {
<a name="l00750"></a>00750 DBusFakeMutex *fake = (DBusFakeMutex*) mutex;
<a name="l00751"></a>00751
<a name="l00752"></a>00752 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (!fake->locked);
<a name="l00753"></a>00753
<a name="l00754"></a>00754 fake->locked = <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00755"></a>00755
<a name="l00756"></a>00756 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00757"></a>00757 }
<a name="l00758"></a>00758
<a name="l00759"></a>00759 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00760"></a>00760 dbus_fake_mutex_unlock (<a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex)
<a name="l00761"></a>00761 {
<a name="l00762"></a>00762 DBusFakeMutex *fake = (DBusFakeMutex*) mutex;
<a name="l00763"></a>00763
<a name="l00764"></a>00764 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (fake->locked);
<a name="l00765"></a>00765
<a name="l00766"></a>00766 fake->locked = <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00767"></a>00767
<a name="l00768"></a>00768 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00769"></a>00769 }
<a name="l00770"></a>00770
<a name="l00771"></a>00771 <span class="keyword">static</span> <a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a>*
<a name="l00772"></a>00772 dbus_fake_condvar_new (<span class="keywordtype">void</span>)
<a name="l00773"></a>00773 {
<a name="l00774"></a>00774 <span class="keywordflow">return</span> (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a>*) <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (<span class="stringliteral">"FakeCondvar"</span>);
<a name="l00775"></a>00775 }
<a name="l00776"></a>00776
<a name="l00777"></a>00777 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00778"></a>00778 dbus_fake_condvar_free (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond)
<a name="l00779"></a>00779 {
<a name="l00780"></a>00780 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (cond);
<a name="l00781"></a>00781 }
<a name="l00782"></a>00782
<a name="l00783"></a>00783 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00784"></a>00784 dbus_fake_condvar_wait (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond,
<a name="l00785"></a>00785 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex)
<a name="l00786"></a>00786 {
<a name="l00787"></a>00787
<a name="l00788"></a>00788 }
<a name="l00789"></a>00789
<a name="l00790"></a>00790 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00791"></a>00791 dbus_fake_condvar_wait_timeout (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond,
<a name="l00792"></a>00792 <a class="code" href="group__DBusThreads.html#g4eb021cd6cd0830423eac2738e0ddc40">DBusMutex</a> *mutex,
<a name="l00793"></a>00793 <span class="keywordtype">int</span> timeout_msec)
<a name="l00794"></a>00794 {
<a name="l00795"></a>00795 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00796"></a>00796 }
<a name="l00797"></a>00797
<a name="l00798"></a>00798 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00799"></a>00799 dbus_fake_condvar_wake_one (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond)
<a name="l00800"></a>00800 {
<a name="l00801"></a>00801
<a name="l00802"></a>00802 }
<a name="l00803"></a>00803
<a name="l00804"></a>00804 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00805"></a>00805 dbus_fake_condvar_wake_all (<a class="code" href="group__DBusThreads.html#ga14cd16a336a85b5edbca3c237c3829e">DBusCondVar</a> *cond)
<a name="l00806"></a>00806 {
<a name="l00807"></a>00807
<a name="l00808"></a>00808 }
<a name="l00809"></a>00809
<a name="l00810"></a>00810 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00811"></a>00811 _dbus_threads_init_debug (<span class="keywordtype">void</span>)
<a name="l00812"></a>00812 {
<a name="l00813"></a>00813 <span class="keywordflow">return</span> <a class="code" href="group__DBusThreads.html#ga9a4ed445c77af3afa0dbdbb9d85afd4">dbus_threads_init</a> (&fake_functions);
<a name="l00814"></a>00814 }
<a name="l00815"></a>00815
<a name="l00816"></a>00816 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Dec 14 22:26:12 2009 for D-Bus by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>