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.

211 lines
14 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::spin_rw_mutex_v3::scoped_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"><a class="el" href="a00128.html">spin_rw_mutex_v3</a></li><li class="navelem"><a class="el" href="a00114.html">scoped_lock</a></li> </ul>
  37. </div>
  38. </div><!-- top -->
  39. <div class="header">
  40. <div class="summary">
  41. <a href="#pub-methods">Public Member Functions</a> &#124;
  42. <a href="#pro-attribs">Protected Attributes</a> &#124;
  43. <a href="a00284.html">List of all members</a> </div>
  44. <div class="headertitle">
  45. <div class="title">tbb::spin_rw_mutex_v3::scoped_lock Class Reference</div> </div>
  46. </div><!--header-->
  47. <div class="contents">
  48. <p>The scoped locking pattern.
  49. <a href="a00114.html#details">More...</a></p>
  50. <p><code>#include &lt;spin_rw_mutex.h&gt;</code></p>
  51. <div class="dynheader">
  52. Inheritance diagram for tbb::spin_rw_mutex_v3::scoped_lock:</div>
  53. <div class="dyncontent">
  54. <div class="center">
  55. <img src="a00114.png" usemap="#tbb::spin_rw_mutex_v3::scoped_lock_map" alt=""/>
  56. <map id="tbb::spin_rw_mutex_v3::scoped_lock_map" name="tbb::spin_rw_mutex_v3::scoped_lock_map">
  57. </map>
  58. </div></div>
  59. <table class="memberdecls">
  60. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
  61. Public Member Functions</h2></td></tr>
  62. <tr class="memitem:a285b355121772c874a7ecaaf4d347224"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#a285b355121772c874a7ecaaf4d347224">scoped_lock</a> ()</td></tr>
  63. <tr class="memdesc:a285b355121772c874a7ecaaf4d347224"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct lock that has not acquired a mutex. <a href="#a285b355121772c874a7ecaaf4d347224">More...</a><br/></td></tr>
  64. <tr class="separator:a285b355121772c874a7ecaaf4d347224"><td class="memSeparator" colspan="2">&#160;</td></tr>
  65. <tr class="memitem:a0a2e15358575f7651446bca13a5a2674"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0a2e15358575f7651446bca13a5a2674"></a>
  66. &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#a0a2e15358575f7651446bca13a5a2674">scoped_lock</a> (<a class="el" href="a00128.html">spin_rw_mutex</a> &amp;m, bool write=true)</td></tr>
  67. <tr class="memdesc:a0a2e15358575f7651446bca13a5a2674"><td class="mdescLeft">&#160;</td><td class="mdescRight">Acquire lock on given mutex. <br/></td></tr>
  68. <tr class="separator:a0a2e15358575f7651446bca13a5a2674"><td class="memSeparator" colspan="2">&#160;</td></tr>
  69. <tr class="memitem:a5c27ca2e0c9db960a9a7430082ff7edd"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5c27ca2e0c9db960a9a7430082ff7edd"></a>
  70. &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#a5c27ca2e0c9db960a9a7430082ff7edd">~scoped_lock</a> ()</td></tr>
  71. <tr class="memdesc:a5c27ca2e0c9db960a9a7430082ff7edd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Release lock (if lock is held). <br/></td></tr>
  72. <tr class="separator:a5c27ca2e0c9db960a9a7430082ff7edd"><td class="memSeparator" colspan="2">&#160;</td></tr>
  73. <tr class="memitem:a6d49df365396ab314e78ba07c6b96433"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6d49df365396ab314e78ba07c6b96433"></a>
  74. void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#a6d49df365396ab314e78ba07c6b96433">acquire</a> (<a class="el" href="a00128.html">spin_rw_mutex</a> &amp;m, bool write=true)</td></tr>
  75. <tr class="memdesc:a6d49df365396ab314e78ba07c6b96433"><td class="mdescLeft">&#160;</td><td class="mdescRight">Acquire lock on given mutex. <br/></td></tr>
  76. <tr class="separator:a6d49df365396ab314e78ba07c6b96433"><td class="memSeparator" colspan="2">&#160;</td></tr>
  77. <tr class="memitem:afbe5de57eadc457518df7a1bb0d30c00"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#afbe5de57eadc457518df7a1bb0d30c00">upgrade_to_writer</a> ()</td></tr>
  78. <tr class="memdesc:afbe5de57eadc457518df7a1bb0d30c00"><td class="mdescLeft">&#160;</td><td class="mdescRight">Upgrade reader to become a writer. <a href="#afbe5de57eadc457518df7a1bb0d30c00">More...</a><br/></td></tr>
  79. <tr class="separator:afbe5de57eadc457518df7a1bb0d30c00"><td class="memSeparator" colspan="2">&#160;</td></tr>
  80. <tr class="memitem:a99e279a995a51abfb87b865e886949f8"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a99e279a995a51abfb87b865e886949f8"></a>
  81. void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#a99e279a995a51abfb87b865e886949f8">release</a> ()</td></tr>
  82. <tr class="memdesc:a99e279a995a51abfb87b865e886949f8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Release lock. <br/></td></tr>
  83. <tr class="separator:a99e279a995a51abfb87b865e886949f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
  84. <tr class="memitem:aa693c05221d977856a98270a255fe5df"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa693c05221d977856a98270a255fe5df"></a>
  85. bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#aa693c05221d977856a98270a255fe5df">downgrade_to_reader</a> ()</td></tr>
  86. <tr class="memdesc:aa693c05221d977856a98270a255fe5df"><td class="mdescLeft">&#160;</td><td class="mdescRight">Downgrade writer to become a reader. <br/></td></tr>
  87. <tr class="separator:aa693c05221d977856a98270a255fe5df"><td class="memSeparator" colspan="2">&#160;</td></tr>
  88. <tr class="memitem:abf17ada91882fd70f139c503c0220f16"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abf17ada91882fd70f139c503c0220f16"></a>
  89. bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#abf17ada91882fd70f139c503c0220f16">try_acquire</a> (<a class="el" href="a00128.html">spin_rw_mutex</a> &amp;m, bool write=true)</td></tr>
  90. <tr class="memdesc:abf17ada91882fd70f139c503c0220f16"><td class="mdescLeft">&#160;</td><td class="mdescRight">Try acquire lock on given mutex. <br/></td></tr>
  91. <tr class="separator:abf17ada91882fd70f139c503c0220f16"><td class="memSeparator" colspan="2">&#160;</td></tr>
  92. <tr class="memitem:ad65afc1689547cba82a4667480806ef5"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad65afc1689547cba82a4667480806ef5"></a>
  93. <a class="el" href="a00128.html">spin_rw_mutex</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>__internal_get_mutex</b> ()</td></tr>
  94. <tr class="separator:ad65afc1689547cba82a4667480806ef5"><td class="memSeparator" colspan="2">&#160;</td></tr>
  95. <tr class="memitem:a50e7a21e905abc3e7448a30972923a36"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a50e7a21e905abc3e7448a30972923a36"></a>
  96. void&#160;</td><td class="memItemRight" valign="bottom"><b>__internal_set_mutex</b> (<a class="el" href="a00128.html">spin_rw_mutex</a> *m)</td></tr>
  97. <tr class="separator:a50e7a21e905abc3e7448a30972923a36"><td class="memSeparator" colspan="2">&#160;</td></tr>
  98. <tr class="memitem:a0bc9be67c5c4f6ffb8ba79baa73448c8"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0bc9be67c5c4f6ffb8ba79baa73448c8"></a>
  99. void&#160;</td><td class="memItemRight" valign="bottom"><b>__internal_set_writer</b> (bool flag=true)</td></tr>
  100. <tr class="separator:a0bc9be67c5c4f6ffb8ba79baa73448c8"><td class="memSeparator" colspan="2">&#160;</td></tr>
  101. </table><table class="memberdecls">
  102. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-attribs"></a>
  103. Protected Attributes</h2></td></tr>
  104. <tr class="memitem:a8d70c5a2348e30a6979bfbf677328dc4"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8d70c5a2348e30a6979bfbf677328dc4"></a>
  105. <a class="el" href="a00128.html">spin_rw_mutex</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#a8d70c5a2348e30a6979bfbf677328dc4">mutex</a></td></tr>
  106. <tr class="memdesc:a8d70c5a2348e30a6979bfbf677328dc4"><td class="mdescLeft">&#160;</td><td class="mdescRight">The pointer to the current mutex that is held, or NULL if no mutex is held. <br/></td></tr>
  107. <tr class="separator:a8d70c5a2348e30a6979bfbf677328dc4"><td class="memSeparator" colspan="2">&#160;</td></tr>
  108. <tr class="memitem:acfd129dc5106ad1129ba803e67311050"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00114.html#acfd129dc5106ad1129ba803e67311050">is_writer</a></td></tr>
  109. <tr class="memdesc:acfd129dc5106ad1129ba803e67311050"><td class="mdescLeft">&#160;</td><td class="mdescRight">If mutex!=NULL, then is_writer is true if holding a writer lock, false if holding a reader lock. <a href="#acfd129dc5106ad1129ba803e67311050">More...</a><br/></td></tr>
  110. <tr class="separator:acfd129dc5106ad1129ba803e67311050"><td class="memSeparator" colspan="2">&#160;</td></tr>
  111. </table>
  112. <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
  113. <div class="textblock"><p>The scoped locking pattern. </p>
  114. <p>It helps to avoid the common problem of forgetting to release lock. It also nicely provides the "node" for queuing locks. </p>
  115. </div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
  116. <a class="anchor" id="a285b355121772c874a7ecaaf4d347224"></a>
  117. <div class="memitem">
  118. <div class="memproto">
  119. <table class="mlabels">
  120. <tr>
  121. <td class="mlabels-left">
  122. <table class="memname">
  123. <tr>
  124. <td class="memname">tbb::spin_rw_mutex_v3::scoped_lock::scoped_lock </td>
  125. <td>(</td>
  126. <td class="paramname">)</td><td></td>
  127. <td></td>
  128. </tr>
  129. </table>
  130. </td>
  131. <td class="mlabels-right">
  132. <span class="mlabels"><span class="mlabel">inline</span></span> </td>
  133. </tr>
  134. </table>
  135. </div><div class="memdoc">
  136. <p>Construct lock that has not acquired a mutex. </p>
  137. <p>Equivalent to zero-initialization of *this. </p>
  138. </div>
  139. </div>
  140. <h2 class="groupheader">Member Function Documentation</h2>
  141. <a class="anchor" id="afbe5de57eadc457518df7a1bb0d30c00"></a>
  142. <div class="memitem">
  143. <div class="memproto">
  144. <table class="mlabels">
  145. <tr>
  146. <td class="mlabels-left">
  147. <table class="memname">
  148. <tr>
  149. <td class="memname">bool tbb::spin_rw_mutex_v3::scoped_lock::upgrade_to_writer </td>
  150. <td>(</td>
  151. <td class="paramname">)</td><td></td>
  152. <td></td>
  153. </tr>
  154. </table>
  155. </td>
  156. <td class="mlabels-right">
  157. <span class="mlabels"><span class="mlabel">inline</span></span> </td>
  158. </tr>
  159. </table>
  160. </div><div class="memdoc">
  161. <p>Upgrade reader to become a writer. </p>
  162. <p>Returns whether the upgrade happened without releasing and re-acquiring the lock </p>
  163. <p>References <a class="el" href="a00114.html#acfd129dc5106ad1129ba803e67311050">is_writer</a>.</p>
  164. </div>
  165. </div>
  166. <h2 class="groupheader">Member Data Documentation</h2>
  167. <a class="anchor" id="acfd129dc5106ad1129ba803e67311050"></a>
  168. <div class="memitem">
  169. <div class="memproto">
  170. <table class="mlabels">
  171. <tr>
  172. <td class="mlabels-left">
  173. <table class="memname">
  174. <tr>
  175. <td class="memname">bool tbb::spin_rw_mutex_v3::scoped_lock::is_writer</td>
  176. </tr>
  177. </table>
  178. </td>
  179. <td class="mlabels-right">
  180. <span class="mlabels"><span class="mlabel">protected</span></span> </td>
  181. </tr>
  182. </table>
  183. </div><div class="memdoc">
  184. <p>If mutex!=NULL, then is_writer is true if holding a writer lock, false if holding a reader lock. </p>
  185. <p>Not defined if not holding a lock. </p>
  186. <p>Referenced by <a class="el" href="a00114.html#a6d49df365396ab314e78ba07c6b96433">acquire()</a>, <a class="el" href="a00114.html#aa693c05221d977856a98270a255fe5df">downgrade_to_reader()</a>, <a class="el" href="a00114.html#a99e279a995a51abfb87b865e886949f8">release()</a>, <a class="el" href="a00114.html#abf17ada91882fd70f139c503c0220f16">try_acquire()</a>, and <a class="el" href="a00114.html#afbe5de57eadc457518df7a1bb0d30c00">upgrade_to_writer()</a>.</p>
  187. </div>
  188. </div>
  189. <hr/>The documentation for this class was generated from the following file:<ul>
  190. <li>spin_rw_mutex.h</li>
  191. </ul>
  192. </div><!-- contents -->
  193. <hr>
  194. <p></p>
  195. Copyright &copy; 2005-2014 Intel Corporation. All Rights Reserved.
  196. <p></p>
  197. Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are
  198. registered trademarks or trademarks of Intel Corporation or its
  199. subsidiaries in the United States and other countries.
  200. <p></p>
  201. * Other names and brands may be claimed as the property of others.