Files
rippled/classripple_1_1scope__unlock.html
2025-01-21 19:58:08 +00:00

299 lines
16 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>rippled: ripple::scope_unlock&lt; Mutex &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">rippled
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.5 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespaceripple.html">ripple</a></li><li class="navelem"><a class="el" href="classripple_1_1scope__unlock.html">scope_unlock</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pri-attribs">Private Attributes</a> &#124;
<a href="classripple_1_1scope__unlock-members.html">List of all members</a> </div>
<div class="headertitle"><div class="title">ripple::scope_unlock&lt; Mutex &gt; Class Template Reference</div></div>
</div><!--header-->
<div class="contents">
<p>Automatically unlocks and re-locks a unique_lock object.
<a href="classripple_1_1scope__unlock.html#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="scope_8h_source.html">scope.h</a>&gt;</code></p>
<div class="dynheader">
Collaboration diagram for ripple::scope_unlock&lt; Mutex &gt;:</div>
<div class="dyncontent">
<div class="center"><img src="classripple_1_1scope__unlock__coll__graph.png" border="0" usemap="#aripple_1_1scope__unlock_3_01Mutex_01_4_coll__map" alt="Collaboration graph"/></div>
<map name="aripple_1_1scope__unlock_3_01Mutex_01_4_coll__map" id="aripple_1_1scope__unlock_3_01Mutex_01_4_coll__map">
<area shape="rect" title="Automatically unlocks and re&#45;locks a unique_lock object." alt="" coords="27,93,182,133"/>
<area shape="rect" target="_parent" href="http://en.cppreference.com/w/cpp/thread/unique_lock.html" title=" " alt="" coords="5,5,204,31"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a0f9308804415b7acbdfb80cbb139e4e0"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classripple_1_1scope__unlock.html#a0f9308804415b7acbdfb80cbb139e4e0">scope_unlock</a> (<a class="elRef" href="http://en.cppreference.com/w/cpp/thread/unique_lock.html">std::unique_lock</a>&lt; Mutex &gt; &amp;lock) noexcept(true)</td></tr>
<tr class="separator:a0f9308804415b7acbdfb80cbb139e4e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af0a960be928e77412052d93ba44e4090"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classripple_1_1scope__unlock.html#af0a960be928e77412052d93ba44e4090">scope_unlock</a> (<a class="el" href="classripple_1_1scope__unlock.html">scope_unlock</a> const &amp;)=delete</td></tr>
<tr class="separator:af0a960be928e77412052d93ba44e4090"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a396c276f96a87258415c1eb9acc008aa"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classripple_1_1scope__unlock.html">scope_unlock</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classripple_1_1scope__unlock.html#a396c276f96a87258415c1eb9acc008aa">operator=</a> (<a class="el" href="classripple_1_1scope__unlock.html">scope_unlock</a> const &amp;)=delete</td></tr>
<tr class="separator:a396c276f96a87258415c1eb9acc008aa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a913d1b81babc4dfff80691f28a914054"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classripple_1_1scope__unlock.html#a913d1b81babc4dfff80691f28a914054">~scope_unlock</a> () noexcept(true)</td></tr>
<tr class="separator:a913d1b81babc4dfff80691f28a914054"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pri-attribs" name="pri-attribs"></a>
Private Attributes</h2></td></tr>
<tr class="memitem:a61f8904806190d58ebea8e44649fc8d7"><td class="memItemLeft" align="right" valign="top"><a class="elRef" href="http://en.cppreference.com/w/cpp/thread/unique_lock.html">std::unique_lock</a>&lt; Mutex &gt; *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classripple_1_1scope__unlock.html#a61f8904806190d58ebea8e44649fc8d7">plock</a></td></tr>
<tr class="separator:a61f8904806190d58ebea8e44649fc8d7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><div class="compoundTemplParams">template&lt;class Mutex&gt;<br />
class ripple::scope_unlock&lt; Mutex &gt;</div><p >Automatically unlocks and re-locks a unique_lock object. </p>
<p >This is the reverse of a <a class="elRef" href="http://en.cppreference.com/w/cpp/thread/unique_lock.html">std::unique_lock</a> object - instead of locking the mutex for the lifetime of this object, it unlocks it.</p>
<p >Make sure you don't try to unlock mutexes that aren't actually locked!</p>
<p >This is essentially a less-versatile boost::reverse_lock.</p>
<p >e.g. </p><div class="fragment"><div class="line"><a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/thread/mutex.html">std::mutex</a> mut;</div>
<div class="line"> </div>
<div class="line"><span class="keywordflow">for</span> (;;)</div>
<div class="line">{</div>
<div class="line"> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/thread/unique_lock.html">std::unique_lock</a> myScopedLock{mut};</div>
<div class="line"> <span class="comment">// mut is now locked</span></div>
<div class="line"> </div>
<div class="line"> ... <span class="keywordflow">do</span> <a class="code hl_enumvalue" href="namespaceripple.html#a7ffb3f54d739bb8f967d695f08fb66cca03d59e663c1af9ac33a9949d1193505a">some</a> stuff with it locked ..</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">while</span> (xyz)</div>
<div class="line"> {</div>
<div class="line"> ... <span class="keywordflow">do</span> <a class="code hl_enumvalue" href="namespaceripple.html#a7ffb3f54d739bb8f967d695f08fb66cca03d59e663c1af9ac33a9949d1193505a">some</a> stuff with it locked ..</div>
<div class="line"> </div>
<div class="line"> <a class="code hl_class" href="classripple_1_1scope__unlock.html">scope_unlock</a> unlocker{myScopedLock};</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// mut is now unlocked for the remainder of this block,</span></div>
<div class="line"> <span class="comment">// and re-locked at the end.</span></div>
<div class="line"> </div>
<div class="line"> ...do <a class="code hl_enumvalue" href="namespaceripple.html#a7ffb3f54d739bb8f967d695f08fb66cca03d59e663c1af9ac33a9949d1193505a">some</a> stuff with it unlocked ...</div>
<div class="line"> } <span class="comment">// mut gets locked here.</span></div>
<div class="line"> </div>
<div class="line">} <span class="comment">// mut gets unlocked here</span></div>
<div class="ttc" id="aclassripple_1_1scope__unlock_html"><div class="ttname"><a href="classripple_1_1scope__unlock.html">ripple::scope_unlock</a></div><div class="ttdoc">Automatically unlocks and re-locks a unique_lock object.</div><div class="ttdef"><b>Definition:</b> <a href="scope_8h_source.html#l00230">scope.h:231</a></div></div>
<div class="ttc" id="amutex_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/thread/mutex.html">std::mutex</a></div></div>
<div class="ttc" id="anamespaceripple_html_a7ffb3f54d739bb8f967d695f08fb66cca03d59e663c1af9ac33a9949d1193505a"><div class="ttname"><a href="namespaceripple.html#a7ffb3f54d739bb8f967d695f08fb66cca03d59e663c1af9ac33a9949d1193505a">ripple::TxSearched::some</a></div><div class="ttdeci">@ some</div></div>
<div class="ttc" id="aunique_lock_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/thread/unique_lock.html">std::unique_lock</a></div></div>
</div><!-- fragment -->
<p class="definition">Definition at line <a class="el" href="scope_8h_source.html#l00230">230</a> of file <a class="el" href="scope_8h_source.html">scope.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a0f9308804415b7acbdfb80cbb139e4e0" name="a0f9308804415b7acbdfb80cbb139e4e0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0f9308804415b7acbdfb80cbb139e4e0">&#9670;&#160;</a></span>scope_unlock() <span class="overload">[1/2]</span></h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Mutex &gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classripple_1_1scope__unlock.html">ripple::scope_unlock</a>&lt; Mutex &gt;::scope_unlock </td>
<td>(</td>
<td class="paramtype"><a class="elRef" href="http://en.cppreference.com/w/cpp/thread/unique_lock.html">std::unique_lock</a>&lt; Mutex &gt; &amp;&#160;</td>
<td class="paramname"><em>lock</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="scope_8h_source.html#l00235">235</a> of file <a class="el" href="scope_8h_source.html">scope.h</a>.</p>
</div>
</div>
<a id="af0a960be928e77412052d93ba44e4090" name="af0a960be928e77412052d93ba44e4090"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af0a960be928e77412052d93ba44e4090">&#9670;&#160;</a></span>scope_unlock() <span class="overload">[2/2]</span></h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Mutex &gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classripple_1_1scope__unlock.html">ripple::scope_unlock</a>&lt; Mutex &gt;::scope_unlock </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classripple_1_1scope__unlock.html">scope_unlock</a>&lt; Mutex &gt; const &amp;&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a913d1b81babc4dfff80691f28a914054" name="a913d1b81babc4dfff80691f28a914054"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a913d1b81babc4dfff80691f28a914054">&#9670;&#160;</a></span>~scope_unlock()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Mutex &gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classripple_1_1scope__unlock.html">ripple::scope_unlock</a>&lt; Mutex &gt;::~<a class="el" href="classripple_1_1scope__unlock.html">scope_unlock</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="scope_8h_source.html#l00249">249</a> of file <a class="el" href="scope_8h_source.html">scope.h</a>.</p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a396c276f96a87258415c1eb9acc008aa" name="a396c276f96a87258415c1eb9acc008aa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a396c276f96a87258415c1eb9acc008aa">&#9670;&#160;</a></span>operator=()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Mutex &gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classripple_1_1scope__unlock.html">scope_unlock</a> &amp; <a class="el" href="classripple_1_1scope__unlock.html">ripple::scope_unlock</a>&lt; Mutex &gt;::operator= </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classripple_1_1scope__unlock.html">scope_unlock</a>&lt; Mutex &gt; const &amp;&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a id="a61f8904806190d58ebea8e44649fc8d7" name="a61f8904806190d58ebea8e44649fc8d7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a61f8904806190d58ebea8e44649fc8d7">&#9670;&#160;</a></span>plock</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Mutex &gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="elRef" href="http://en.cppreference.com/w/cpp/thread/unique_lock.html">std::unique_lock</a>&lt;Mutex&gt;* <a class="el" href="classripple_1_1scope__unlock.html">ripple::scope_unlock</a>&lt; Mutex &gt;::plock</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="scope_8h_source.html#l00232">232</a> of file <a class="el" href="scope_8h_source.html">scope.h</a>.</p>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5
</small></address>
</body>
</html>