You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

231 lines
17 KiB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.4"/>
  7. <title>tbb::interface5::reader_writer_lock Class Reference</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  12. </head>
  13. <body>
  14. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  15. <!-- end header part -->
  16. <!-- Generated by Doxygen 1.8.4 -->
  17. <div id="navrow1" class="tabs">
  18. <ul class="tablist">
  19. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  20. <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
  21. <li><a href="modules.html"><span>Modules</span></a></li>
  22. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  23. <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
  24. <li><a href="files.html"><span>Files</span></a></li>
  25. </ul>
  26. </div>
  27. <div id="navrow2" class="tabs2">
  28. <ul class="tablist">
  29. <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
  30. <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
  31. <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
  32. </ul>
  33. </div>
  34. <div id="nav-path" class="navpath">
  35. <ul>
  36. <li class="navelem"><a class="el" href="a00222.html">tbb</a></li><li class="navelem"><b>interface5</b></li><li class="navelem"><a class="el" href="a00095.html">reader_writer_lock</a></li> </ul>
  37. </div>
  38. </div><!-- top -->
  39. <div class="header">
  40. <div class="summary">
  41. <a href="#nested-classes">Classes</a> &#124;
  42. <a href="#pub-types">Public Types</a> &#124;
  43. <a href="#pub-methods">Public Member Functions</a> &#124;
  44. <a href="#friends">Friends</a> &#124;
  45. <a href="a00347.html">List of all members</a> </div>
  46. <div class="headertitle">
  47. <div class="title">tbb::interface5::reader_writer_lock Class Reference<div class="ingroups"><a class="el" href="a00237.html">Synchronization</a></div></div> </div>
  48. </div><!--header-->
  49. <div class="contents">
  50. <p>Writer-preference reader-writer lock with local-only spinning on readers.
  51. <a href="a00095.html#details">More...</a></p>
  52. <p><code>#include &lt;reader_writer_lock.h&gt;</code></p>
  53. <div class="dynheader">
  54. Inheritance diagram for tbb::interface5::reader_writer_lock:</div>
  55. <div class="dyncontent">
  56. <div class="center">
  57. <img src="a00095.png" usemap="#tbb::interface5::reader_writer_lock_map" alt=""/>
  58. <map id="tbb::interface5::reader_writer_lock_map" name="tbb::interface5::reader_writer_lock_map">
  59. </map>
  60. </div></div>
  61. <table class="memberdecls">
  62. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
  63. Classes</h2></td></tr>
  64. <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00118.html">scoped_lock</a></td></tr>
  65. <tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">The scoped lock pattern for write locks. <a href="a00118.html#details">More...</a><br/></td></tr>
  66. <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
  67. <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00123.html">scoped_lock_read</a></td></tr>
  68. <tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">The scoped lock pattern for read locks. <a href="a00123.html#details">More...</a><br/></td></tr>
  69. <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
  70. </table><table class="memberdecls">
  71. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
  72. Public Types</h2></td></tr>
  73. <tr class="memitem:a29bbf9ca21c12b313d9fa5326feaf3ed"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a29bbf9ca21c12b313d9fa5326feaf3ed">status_t</a> { <b>waiting_nonblocking</b>,
  74. <b>waiting</b>,
  75. <b>active</b>,
  76. <b>invalid</b>
  77. }</td></tr>
  78. <tr class="memdesc:a29bbf9ca21c12b313d9fa5326feaf3ed"><td class="mdescLeft">&#160;</td><td class="mdescRight">Status type for nodes associated with lock instances. <a href="a00095.html#a29bbf9ca21c12b313d9fa5326feaf3ed">More...</a><br/></td></tr>
  79. <tr class="separator:a29bbf9ca21c12b313d9fa5326feaf3ed"><td class="memSeparator" colspan="2">&#160;</td></tr>
  80. </table><table class="memberdecls">
  81. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
  82. Public Member Functions</h2></td></tr>
  83. <tr class="memitem:abceda6c50b0c36eacbef51f4682742f3"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abceda6c50b0c36eacbef51f4682742f3"></a>
  84. &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#abceda6c50b0c36eacbef51f4682742f3">reader_writer_lock</a> ()</td></tr>
  85. <tr class="memdesc:abceda6c50b0c36eacbef51f4682742f3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a new <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a>. <br/></td></tr>
  86. <tr class="separator:abceda6c50b0c36eacbef51f4682742f3"><td class="memSeparator" colspan="2">&#160;</td></tr>
  87. <tr class="memitem:aeee96b648c7b5ff6126c8a2e13ec7241"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aeee96b648c7b5ff6126c8a2e13ec7241"></a>
  88. &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#aeee96b648c7b5ff6126c8a2e13ec7241">~reader_writer_lock</a> ()</td></tr>
  89. <tr class="memdesc:aeee96b648c7b5ff6126c8a2e13ec7241"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructs a <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> object. <br/></td></tr>
  90. <tr class="separator:aeee96b648c7b5ff6126c8a2e13ec7241"><td class="memSeparator" colspan="2">&#160;</td></tr>
  91. <tr class="memitem:af92eb949fc491af8f7e350869ea0a0d1"><td class="memItemLeft" align="right" valign="top">void __TBB_EXPORTED_METHOD&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#af92eb949fc491af8f7e350869ea0a0d1">lock</a> ()</td></tr>
  92. <tr class="memdesc:af92eb949fc491af8f7e350869ea0a0d1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Acquires the <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> for write. <a href="#af92eb949fc491af8f7e350869ea0a0d1">More...</a><br/></td></tr>
  93. <tr class="separator:af92eb949fc491af8f7e350869ea0a0d1"><td class="memSeparator" colspan="2">&#160;</td></tr>
  94. <tr class="memitem:a1739e842af52925a2d4a7e821b9b3b8d"><td class="memItemLeft" align="right" valign="top">bool __TBB_EXPORTED_METHOD&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a1739e842af52925a2d4a7e821b9b3b8d">try_lock</a> ()</td></tr>
  95. <tr class="memdesc:a1739e842af52925a2d4a7e821b9b3b8d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Tries to acquire the <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> for write. <a href="#a1739e842af52925a2d4a7e821b9b3b8d">More...</a><br/></td></tr>
  96. <tr class="separator:a1739e842af52925a2d4a7e821b9b3b8d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  97. <tr class="memitem:a6fd4fcdf0e5c0425d1cc736d644f234f"><td class="memItemLeft" align="right" valign="top">void __TBB_EXPORTED_METHOD&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a6fd4fcdf0e5c0425d1cc736d644f234f">lock_read</a> ()</td></tr>
  98. <tr class="memdesc:a6fd4fcdf0e5c0425d1cc736d644f234f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Acquires the <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> for read. <a href="#a6fd4fcdf0e5c0425d1cc736d644f234f">More...</a><br/></td></tr>
  99. <tr class="separator:a6fd4fcdf0e5c0425d1cc736d644f234f"><td class="memSeparator" colspan="2">&#160;</td></tr>
  100. <tr class="memitem:a9c7aa04e00202c9a1197cb6d870cabb4"><td class="memItemLeft" align="right" valign="top">bool __TBB_EXPORTED_METHOD&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a9c7aa04e00202c9a1197cb6d870cabb4">try_lock_read</a> ()</td></tr>
  101. <tr class="memdesc:a9c7aa04e00202c9a1197cb6d870cabb4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Tries to acquire the <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> for read. <a href="#a9c7aa04e00202c9a1197cb6d870cabb4">More...</a><br/></td></tr>
  102. <tr class="separator:a9c7aa04e00202c9a1197cb6d870cabb4"><td class="memSeparator" colspan="2">&#160;</td></tr>
  103. <tr class="memitem:a4c55c4dbde63e950fdc843c9b01a174f"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4c55c4dbde63e950fdc843c9b01a174f"></a>
  104. void __TBB_EXPORTED_METHOD&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a4c55c4dbde63e950fdc843c9b01a174f">unlock</a> ()</td></tr>
  105. <tr class="memdesc:a4c55c4dbde63e950fdc843c9b01a174f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Releases the <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a>. <br/></td></tr>
  106. <tr class="separator:a4c55c4dbde63e950fdc843c9b01a174f"><td class="memSeparator" colspan="2">&#160;</td></tr>
  107. </table><table class="memberdecls">
  108. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="friends"></a>
  109. Friends</h2></td></tr>
  110. <tr class="memitem:afcf922650b2fd9d76b7b939d8511bbd8"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afcf922650b2fd9d76b7b939d8511bbd8"></a>
  111. class&#160;</td><td class="memItemRight" valign="bottom"><b>scoped_lock</b></td></tr>
  112. <tr class="separator:afcf922650b2fd9d76b7b939d8511bbd8"><td class="memSeparator" colspan="2">&#160;</td></tr>
  113. <tr class="memitem:a578ccbc6ecbc6d32cb45ccfdc0ed4ee6"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a578ccbc6ecbc6d32cb45ccfdc0ed4ee6"></a>
  114. class&#160;</td><td class="memItemRight" valign="bottom"><b>scoped_lock_read</b></td></tr>
  115. <tr class="separator:a578ccbc6ecbc6d32cb45ccfdc0ed4ee6"><td class="memSeparator" colspan="2">&#160;</td></tr>
  116. </table>
  117. <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
  118. <div class="textblock"><p>Writer-preference reader-writer lock with local-only spinning on readers. </p>
  119. <p>Loosely adapted from Mellor-Crummey and Scott pseudocode at <a href="http://www.cs.rochester.edu/research/synchronization/pseudocode/rw.html#s_wp">http://www.cs.rochester.edu/research/synchronization/pseudocode/rw.html#s_wp</a> </p>
  120. </div><h2 class="groupheader">Member Enumeration Documentation</h2>
  121. <a class="anchor" id="a29bbf9ca21c12b313d9fa5326feaf3ed"></a>
  122. <div class="memitem">
  123. <div class="memproto">
  124. <table class="memname">
  125. <tr>
  126. <td class="memname">enum <a class="el" href="a00095.html#a29bbf9ca21c12b313d9fa5326feaf3ed">tbb::interface5::reader_writer_lock::status_t</a></td>
  127. </tr>
  128. </table>
  129. </div><div class="memdoc">
  130. <p>Status type for nodes associated with lock instances. </p>
  131. <p>waiting_nonblocking: the wait state for nonblocking lock instances; for writes, these transition straight to active states; for reads, these are unused.</p>
  132. <p>waiting: the start and spin state for all lock instances; these will transition to active state when appropriate. Non-blocking write locks transition from this state to waiting_nonblocking immediately.</p>
  133. <p>active: the active state means that the lock instance holds the lock; it will transition to invalid state during node deletion</p>
  134. <p>invalid: the end state for all nodes; this is set in the destructor so if we encounter this state, we are looking at memory that has already been freed</p>
  135. <p>The state diagrams below describe the status transitions. Single arrows indicate that the thread that owns the node is responsible for the transition; double arrows indicate that any thread could make the transition.</p>
  136. <p>State diagram for <a class="el" href="a00118.html" title="The scoped lock pattern for write locks. ">scoped_lock</a> status:</p>
  137. <p>waiting -------&mdash;&gt; waiting_nonblocking | _____________/ | V V V active --------------&mdash;&gt; invalid</p>
  138. <p>State diagram for <a class="el" href="a00123.html" title="The scoped lock pattern for read locks. ">scoped_lock_read</a> status:</p>
  139. <p>waiting | V active --------------&mdash;&gt;invalid </p>
  140. </div>
  141. </div>
  142. <h2 class="groupheader">Member Function Documentation</h2>
  143. <a class="anchor" id="af92eb949fc491af8f7e350869ea0a0d1"></a>
  144. <div class="memitem">
  145. <div class="memproto">
  146. <table class="memname">
  147. <tr>
  148. <td class="memname">void __TBB_EXPORTED_METHOD tbb::interface5::reader_writer_lock::lock </td>
  149. <td>(</td>
  150. <td class="paramname">)</td><td></td>
  151. <td></td>
  152. </tr>
  153. </table>
  154. </div><div class="memdoc">
  155. <p>Acquires the <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> for write. </p>
  156. <p>If the lock is currently held in write mode by another context, the writer will block by spinning on a local variable. Exceptions thrown: <a class="el" href="a00065.html" title="Exception for PPL locks. ">improper_lock</a> The context tries to acquire a <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> that it already has write ownership of. </p>
  157. </div>
  158. </div>
  159. <a class="anchor" id="a6fd4fcdf0e5c0425d1cc736d644f234f"></a>
  160. <div class="memitem">
  161. <div class="memproto">
  162. <table class="memname">
  163. <tr>
  164. <td class="memname">void __TBB_EXPORTED_METHOD tbb::interface5::reader_writer_lock::lock_read </td>
  165. <td>(</td>
  166. <td class="paramname">)</td><td></td>
  167. <td></td>
  168. </tr>
  169. </table>
  170. </div><div class="memdoc">
  171. <p>Acquires the <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> for read. </p>
  172. <p>If the lock is currently held by a writer, this reader will block and wait until the writers are done. Exceptions thrown: <a class="el" href="a00065.html" title="Exception for PPL locks. ">improper_lock</a> The context tries to acquire a <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> that it already has write ownership of. </p>
  173. </div>
  174. </div>
  175. <a class="anchor" id="a1739e842af52925a2d4a7e821b9b3b8d"></a>
  176. <div class="memitem">
  177. <div class="memproto">
  178. <table class="memname">
  179. <tr>
  180. <td class="memname">bool __TBB_EXPORTED_METHOD tbb::interface5::reader_writer_lock::try_lock </td>
  181. <td>(</td>
  182. <td class="paramname">)</td><td></td>
  183. <td></td>
  184. </tr>
  185. </table>
  186. </div><div class="memdoc">
  187. <p>Tries to acquire the <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> for write. </p>
  188. <p>This function does not block. Return Value: True or false, depending on whether the lock is acquired or not. If the lock is already held by this acquiring context, <a class="el" href="a00095.html#a1739e842af52925a2d4a7e821b9b3b8d" title="Tries to acquire the reader_writer_lock for write. ">try_lock()</a> returns false. </p>
  189. </div>
  190. </div>
  191. <a class="anchor" id="a9c7aa04e00202c9a1197cb6d870cabb4"></a>
  192. <div class="memitem">
  193. <div class="memproto">
  194. <table class="memname">
  195. <tr>
  196. <td class="memname">bool __TBB_EXPORTED_METHOD tbb::interface5::reader_writer_lock::try_lock_read </td>
  197. <td>(</td>
  198. <td class="paramname">)</td><td></td>
  199. <td></td>
  200. </tr>
  201. </table>
  202. </div><div class="memdoc">
  203. <p>Tries to acquire the <a class="el" href="a00095.html" title="Writer-preference reader-writer lock with local-only spinning on readers. ">reader_writer_lock</a> for read. </p>
  204. <p>This function does not block. Return Value: True or false, depending on whether the lock is acquired or not. </p>
  205. </div>
  206. </div>
  207. <hr/>The documentation for this class was generated from the following file:<ul>
  208. <li>reader_writer_lock.h</li>
  209. </ul>
  210. </div><!-- contents -->
  211. <hr>
  212. <p></p>
  213. Copyright &copy; 2005-2014 Intel Corporation. All Rights Reserved.
  214. <p></p>
  215. Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are
  216. registered trademarks or trademarks of Intel Corporation or its
  217. subsidiaries in the United States and other countries.
  218. <p></p>
  219. * Other names and brands may be claimed as the property of others.