File size: 11,867 Bytes
53a37cf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>threads: interfaces for thread handling</title>
<meta name="generator" content="Libxml2 devhelp stylesheet">
<link rel="start" href="index.html" title="libxml2 Reference Manual">
<link rel="up" href="general.html" title="API">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="general.html" title="API">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="libxml2-schematron.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="general.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<td><a accesskey="n" href="libxml2-tree.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
<th width="100%" align="center">libxml2 Reference Manual</th>
</tr></table>
<h2><span class="refentrytitle">threads</span></h2>
<p>threads - interfaces for thread handling</p>
<p>set of generic threading related routines should work with pthreads, Windows native or TLS threads </p>
<p>Author(s): Daniel Veillard </p>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">typedef struct _xmlMutex <a href="#xmlMutex">xmlMutex</a>;
typedef <a href="libxml2-threads.html#xmlMutex">xmlMutex</a> * <a href="#xmlMutexPtr">xmlMutexPtr</a>;
typedef struct _xmlRMutex <a href="#xmlRMutex">xmlRMutex</a>;
typedef <a href="libxml2-threads.html#xmlRMutex">xmlRMutex</a> * <a href="#xmlRMutexPtr">xmlRMutexPtr</a>;
int <a href="#xmlCheckThreadLocalStorage">xmlCheckThreadLocalStorage</a> (void);
void <a href="#xmlCleanupThreads">xmlCleanupThreads</a> (void);
void <a href="#xmlFreeMutex">xmlFreeMutex</a> (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok);
void <a href="#xmlFreeRMutex">xmlFreeRMutex</a> (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok);
int <a href="#xmlGetThreadId">xmlGetThreadId</a> (void);
void <a href="#xmlInitThreads">xmlInitThreads</a> (void);
int <a href="#xmlIsMainThread">xmlIsMainThread</a> (void);
void <a href="#xmlLockLibrary">xmlLockLibrary</a> (void);
void <a href="#xmlMutexLock">xmlMutexLock</a> (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok);
void <a href="#xmlMutexUnlock">xmlMutexUnlock</a> (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok);
<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> <a href="#xmlNewMutex">xmlNewMutex</a> (void);
<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> <a href="#xmlNewRMutex">xmlNewRMutex</a> (void);
void <a href="#xmlRMutexLock">xmlRMutexLock</a> (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok);
void <a href="#xmlRMutexUnlock">xmlRMutexUnlock</a> (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok);
void <a href="#xmlUnlockLibrary">xmlUnlockLibrary</a> (void);
</pre>
</div>
<div class="refsect1" lang="en"><h2>Description</h2></div>
<div class="refsect1" lang="en">
<h2>Details</h2>
<div class="refsect2" lang="en">
<div class="refsect2" lang="en">
<h3>
<a name="xmlMutex">Structure </a>xmlMutex</h3>
<pre class="programlisting">struct _xmlMutex {
The content of this structure is not made public by the API.
} xmlMutex;
</pre>
<p></p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlMutexPtr">Typedef </a>xmlMutexPtr</h3>
<pre class="programlisting"><a href="libxml2-threads.html#xmlMutex">xmlMutex</a> * xmlMutexPtr;
</pre>
<p></p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlRMutex">Structure </a>xmlRMutex</h3>
<pre class="programlisting">struct _xmlRMutex {
The content of this structure is not made public by the API.
} xmlRMutex;
</pre>
<p></p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlRMutexPtr">Typedef </a>xmlRMutexPtr</h3>
<pre class="programlisting"><a href="libxml2-threads.html#xmlRMutex">xmlRMutex</a> * xmlRMutexPtr;
</pre>
<p></p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlCheckThreadLocalStorage"></a>xmlCheckThreadLocalStorage ()</h3>
<pre class="programlisting">int xmlCheckThreadLocalStorage (void)<br>
</pre>
<p>Check whether thread-local storage could be allocated. In cross-platform code running in multithreaded environments, this function should be called once in each thread before calling other library functions to make sure that thread-local storage was allocated properly.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>0 on success or -1 if a memory allocation failed. A failed allocation signals a typically fatal and irrecoverable out-of-memory situation. Don't call any library functions in this case. This function never fails if the library is compiled with support for thread-local storage. This function never fails for the "main" thread which is the first thread calling <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>. Available since v2.12.0.</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlCleanupThreads"></a>xmlCleanupThreads ()</h3>
<pre class="programlisting">void xmlCleanupThreads (void)<br>
</pre>
<p>DEPRECATED: This function is a no-op. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all.</p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlFreeMutex"></a>xmlFreeMutex ()</h3>
<pre class="programlisting">void xmlFreeMutex (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)<br>
</pre>
<p>Free a mutex.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>tok</tt></i>:</span></td>
<td>the simple mutex</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlFreeRMutex"></a>xmlFreeRMutex ()</h3>
<pre class="programlisting">void xmlFreeRMutex (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok)<br>
</pre>
<p>xmlRFreeMutex() is used to reclaim resources associated with a reentrant mutex.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>tok</tt></i>:</span></td>
<td>the reentrant mutex</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlGetThreadId"></a>xmlGetThreadId ()</h3>
<pre class="programlisting">int xmlGetThreadId (void)<br>
</pre>
<p>DEPRECATED: Internal function, do not use. xmlGetThreadId() find the current thread ID number Note that this is likely to be broken on some platforms using pthreads as the specification doesn't mandate pthread_t to be an integer type</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the current thread ID number</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlInitThreads"></a>xmlInitThreads ()</h3>
<pre class="programlisting">void xmlInitThreads (void)<br>
</pre>
<p>DEPRECATED: Alias for <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>.</p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlIsMainThread"></a>xmlIsMainThread ()</h3>
<pre class="programlisting">int xmlIsMainThread (void)<br>
</pre>
<p>DEPRECATED: Internal function, do not use. Check whether the current thread is the main thread.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>1 if the current thread is the main thread, 0 otherwise</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlLockLibrary"></a>xmlLockLibrary ()</h3>
<pre class="programlisting">void xmlLockLibrary (void)<br>
</pre>
<p>xmlLockLibrary() is used to take out a re-entrant lock on the libxml2 library.</p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlMutexLock"></a>xmlMutexLock ()</h3>
<pre class="programlisting">void xmlMutexLock (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)<br>
</pre>
<p>xmlMutexLock() is used to lock a libxml2 token.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>tok</tt></i>:</span></td>
<td>the simple mutex</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlMutexUnlock"></a>xmlMutexUnlock ()</h3>
<pre class="programlisting">void xmlMutexUnlock (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)<br>
</pre>
<p>xmlMutexUnlock() is used to unlock a libxml2 token.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>tok</tt></i>:</span></td>
<td>the simple mutex</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlNewMutex"></a>xmlNewMutex ()</h3>
<pre class="programlisting"><a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> xmlNewMutex (void)<br>
</pre>
<p>xmlNewMutex() is used to allocate a libxml2 token struct for use in synchronizing access to data.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>a new simple mutex pointer or NULL in case of error</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlNewRMutex"></a>xmlNewRMutex ()</h3>
<pre class="programlisting"><a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> xmlNewRMutex (void)<br>
</pre>
<p>xmlRNewMutex() is used to allocate a reentrant mutex for use in synchronizing access to data. token_r is a re-entrant lock and thus useful for synchronizing access to data structures that may be manipulated in a recursive fashion.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the new reentrant mutex pointer or NULL in case of error</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlRMutexLock"></a>xmlRMutexLock ()</h3>
<pre class="programlisting">void xmlRMutexLock (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok)<br>
</pre>
<p>xmlRMutexLock() is used to lock a libxml2 token_r.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>tok</tt></i>:</span></td>
<td>the reentrant mutex</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlRMutexUnlock"></a>xmlRMutexUnlock ()</h3>
<pre class="programlisting">void xmlRMutexUnlock (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok)<br>
</pre>
<p>xmlRMutexUnlock() is used to unlock a libxml2 token_r.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>tok</tt></i>:</span></td>
<td>the reentrant mutex</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlUnlockLibrary"></a>xmlUnlockLibrary ()</h3>
<pre class="programlisting">void xmlUnlockLibrary (void)<br>
</pre>
<p>xmlUnlockLibrary() is used to release a re-entrant lock on the libxml2 library.</p>
</div>
<hr>
</div>
</div>
</body>
</html>
|