libxml2-threads.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  5. <title>threads: interfaces for thread handling</title>
  6. <meta name="generator" content="Libxml2 devhelp stylesheet"/>
  7. <link rel="start" href="index.html" title="libxml2 Reference Manual"/>
  8. <link rel="up" href="general.html" title="API"/>
  9. <link rel="stylesheet" href="style.css" type="text/css"/>
  10. <link rel="chapter" href="general.html" title="API"/>
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
  14. <tr valign="middle">
  15. <td>
  16. <a accesskey="p" href="libxml2-schematron.html">
  17. <img src="left.png" width="24" height="24" border="0" alt="Prev"/>
  18. </a>
  19. </td>
  20. <td>
  21. <a accesskey="u" href="general.html">
  22. <img src="up.png" width="24" height="24" border="0" alt="Up"/>
  23. </a>
  24. </td>
  25. <td>
  26. <a accesskey="h" href="index.html">
  27. <img src="home.png" width="24" height="24" border="0" alt="Home"/>
  28. </a>
  29. </td>
  30. <td>
  31. <a accesskey="n" href="libxml2-tree.html">
  32. <img src="right.png" width="24" height="24" border="0" alt="Next"/>
  33. </a>
  34. </td>
  35. <th width="100%" align="center">libxml2 Reference Manual</th>
  36. </tr>
  37. </table>
  38. <h2>
  39. <span class="refentrytitle">threads</span>
  40. </h2>
  41. <p>threads - interfaces for thread handling</p>
  42. <p>set of generic threading related routines should work with pthreads, Windows native or TLS threads </p>
  43. <p>Author(s): Daniel Veillard </p>
  44. <div class="refsynopsisdiv">
  45. <h2>Synopsis</h2>
  46. <pre class="synopsis">typedef struct _xmlMutex <a href="#xmlMutex">xmlMutex</a>;
  47. typedef struct _xmlRMutex <a href="#xmlRMutex">xmlRMutex</a>;
  48. typedef <a href="libxml2-threads.html#xmlRMutex">xmlRMutex</a> * <a href="#xmlRMutexPtr">xmlRMutexPtr</a>;
  49. typedef <a href="libxml2-threads.html#xmlMutex">xmlMutex</a> * <a href="#xmlMutexPtr">xmlMutexPtr</a>;
  50. void <a href="#xmlFreeRMutex">xmlFreeRMutex</a> (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok);
  51. int <a href="#xmlGetThreadId">xmlGetThreadId</a> (void);
  52. void <a href="#xmlMutexUnlock">xmlMutexUnlock</a> (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok);
  53. void <a href="#xmlCleanupThreads">xmlCleanupThreads</a> (void);
  54. void <a href="#xmlLockLibrary">xmlLockLibrary</a> (void);
  55. <a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> <a href="#xmlNewRMutex">xmlNewRMutex</a> (void);
  56. void <a href="#xmlMutexLock">xmlMutexLock</a> (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok);
  57. int <a href="#xmlIsMainThread">xmlIsMainThread</a> (void);
  58. void <a href="#xmlRMutexUnlock">xmlRMutexUnlock</a> (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok);
  59. <a href="libxml2-globals.html#xmlGlobalStatePtr">xmlGlobalStatePtr</a> <a href="#xmlGetGlobalState">xmlGetGlobalState</a> (void);
  60. <a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> <a href="#xmlNewMutex">xmlNewMutex</a> (void);
  61. int <a href="#xmlDllMain">xmlDllMain</a> (void * hinstDLL, <br/> unsigned long fdwReason, <br/> void * lpvReserved);
  62. void <a href="#xmlFreeMutex">xmlFreeMutex</a> (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok);
  63. void <a href="#xmlUnlockLibrary">xmlUnlockLibrary</a> (void);
  64. void <a href="#xmlInitThreads">xmlInitThreads</a> (void);
  65. void <a href="#xmlRMutexLock">xmlRMutexLock</a> (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok);
  66. </pre>
  67. </div>
  68. <div class="refsect1" lang="en">
  69. <h2>Description</h2>
  70. </div>
  71. <div class="refsect1" lang="en">
  72. <h2>Details</h2>
  73. <div class="refsect2" lang="en">
  74. <div class="refsect2" lang="en"><h3><a name="xmlMutex">Structure </a>xmlMutex</h3><pre class="programlisting">struct _xmlMutex {
  75. The content of this structure is not made public by the API.
  76. } xmlMutex;
  77. </pre><p/>
  78. </div>
  79. <hr/>
  80. <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;
  81. </pre><p/>
  82. </div>
  83. <hr/>
  84. <div class="refsect2" lang="en"><h3><a name="xmlRMutex">Structure </a>xmlRMutex</h3><pre class="programlisting">struct _xmlRMutex {
  85. The content of this structure is not made public by the API.
  86. } xmlRMutex;
  87. </pre><p/>
  88. </div>
  89. <hr/>
  90. <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;
  91. </pre><p/>
  92. </div>
  93. <hr/>
  94. <div class="refsect2" lang="en"><h3><a name="xmlCleanupThreads"/>xmlCleanupThreads ()</h3><pre class="programlisting">void xmlCleanupThreads (void)<br/>
  95. </pre><p>xmlCleanupThreads() is used to to cleanup all the thread related data of the libxml2 library once processing has ended. WARNING: if your application is multithreaded or has plugin support calling this may crash the application if another thread or a plugin is still using libxml2. It's sometimes very hard to guess if libxml2 is in use in the application, some libraries or plugins may use it without notice. In case of doubt abstain from calling this function or do it just before calling exit() to avoid leak reports from valgrind !</p>
  96. </div>
  97. <hr/>
  98. <div class="refsect2" lang="en"><h3><a name="xmlDllMain"/>xmlDllMain ()</h3><pre class="programlisting">int xmlDllMain (void * hinstDLL, <br/> unsigned long fdwReason, <br/> void * lpvReserved)<br/>
  99. </pre><p/>
  100. <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>hinstDLL</tt></i>:</span></td><td/></tr><tr><td><span class="term"><i><tt>fdwReason</tt></i>:</span></td><td/></tr><tr><td><span class="term"><i><tt>lpvReserved</tt></i>:</span></td><td/></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td/></tr></tbody></table></div></div>
  101. <hr/>
  102. <div class="refsect2" lang="en"><h3><a name="xmlFreeMutex"/>xmlFreeMutex ()</h3><pre class="programlisting">void xmlFreeMutex (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)<br/>
  103. </pre><p>xmlFreeMutex() is used to reclaim resources associated with a libxml2 token struct.</p>
  104. <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>
  105. <hr/>
  106. <div class="refsect2" lang="en"><h3><a name="xmlFreeRMutex"/>xmlFreeRMutex ()</h3><pre class="programlisting">void xmlFreeRMutex (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok)<br/>
  107. </pre><p>xmlRFreeMutex() is used to reclaim resources associated with a reentrant mutex.</p>
  108. <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>
  109. <hr/>
  110. <div class="refsect2" lang="en"><h3><a name="xmlGetGlobalState"/>xmlGetGlobalState ()</h3><pre class="programlisting"><a href="libxml2-globals.html#xmlGlobalStatePtr">xmlGlobalStatePtr</a> xmlGetGlobalState (void)<br/>
  111. </pre><p>xmlGetGlobalState() is called to retrieve the global state for a thread.</p>
  112. <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the thread global state or NULL in case of error</td></tr></tbody></table></div></div>
  113. <hr/>
  114. <div class="refsect2" lang="en"><h3><a name="xmlGetThreadId"/>xmlGetThreadId ()</h3><pre class="programlisting">int xmlGetThreadId (void)<br/>
  115. </pre><p>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>
  116. <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>
  117. <hr/>
  118. <div class="refsect2" lang="en"><h3><a name="xmlInitThreads"/>xmlInitThreads ()</h3><pre class="programlisting">void xmlInitThreads (void)<br/>
  119. </pre><p>xmlInitThreads() is used to to initialize all the thread related data of the libxml2 library.</p>
  120. </div>
  121. <hr/>
  122. <div class="refsect2" lang="en"><h3><a name="xmlIsMainThread"/>xmlIsMainThread ()</h3><pre class="programlisting">int xmlIsMainThread (void)<br/>
  123. </pre><p>xmlIsMainThread() check whether the current thread is the main thread.</p>
  124. <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>
  125. <hr/>
  126. <div class="refsect2" lang="en"><h3><a name="xmlLockLibrary"/>xmlLockLibrary ()</h3><pre class="programlisting">void xmlLockLibrary (void)<br/>
  127. </pre><p>xmlLockLibrary() is used to take out a re-entrant lock on the libxml2 library.</p>
  128. </div>
  129. <hr/>
  130. <div class="refsect2" lang="en"><h3><a name="xmlMutexLock"/>xmlMutexLock ()</h3><pre class="programlisting">void xmlMutexLock (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)<br/>
  131. </pre><p>xmlMutexLock() is used to lock a libxml2 token.</p>
  132. <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>
  133. <hr/>
  134. <div class="refsect2" lang="en"><h3><a name="xmlMutexUnlock"/>xmlMutexUnlock ()</h3><pre class="programlisting">void xmlMutexUnlock (<a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)<br/>
  135. </pre><p>xmlMutexUnlock() is used to unlock a libxml2 token.</p>
  136. <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>
  137. <hr/>
  138. <div class="refsect2" lang="en"><h3><a name="xmlNewMutex"/>xmlNewMutex ()</h3><pre class="programlisting"><a href="libxml2-threads.html#xmlMutexPtr">xmlMutexPtr</a> xmlNewMutex (void)<br/>
  139. </pre><p>xmlNewMutex() is used to allocate a libxml2 token struct for use in synchronizing access to data.</p>
  140. <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>
  141. <hr/>
  142. <div class="refsect2" lang="en"><h3><a name="xmlNewRMutex"/>xmlNewRMutex ()</h3><pre class="programlisting"><a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> xmlNewRMutex (void)<br/>
  143. </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>
  144. <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>
  145. <hr/>
  146. <div class="refsect2" lang="en"><h3><a name="xmlRMutexLock"/>xmlRMutexLock ()</h3><pre class="programlisting">void xmlRMutexLock (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok)<br/>
  147. </pre><p>xmlRMutexLock() is used to lock a libxml2 token_r.</p>
  148. <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>
  149. <hr/>
  150. <div class="refsect2" lang="en"><h3><a name="xmlRMutexUnlock"/>xmlRMutexUnlock ()</h3><pre class="programlisting">void xmlRMutexUnlock (<a href="libxml2-threads.html#xmlRMutexPtr">xmlRMutexPtr</a> tok)<br/>
  151. </pre><p>xmlRMutexUnlock() is used to unlock a libxml2 token_r.</p>
  152. <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>
  153. <hr/>
  154. <div class="refsect2" lang="en"><h3><a name="xmlUnlockLibrary"/>xmlUnlockLibrary ()</h3><pre class="programlisting">void xmlUnlockLibrary (void)<br/>
  155. </pre><p>xmlUnlockLibrary() is used to release a re-entrant lock on the libxml2 library.</p>
  156. </div>
  157. <hr/>
  158. </div>
  159. </div>
  160. </body>
  161. </html>