mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-02-02 20:31:22 +00:00
155 lines
8.5 KiB
HTML
155 lines
8.5 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||
|
<title>TinyThread++: condition_variable Class Reference</title>
|
||
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||
|
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
|
||
|
</head>
|
||
|
<body>
|
||
|
<!-- Generated by Doxygen 1.6.3 -->
|
||
|
<div class="navigation" id="top">
|
||
|
<div class="tabs">
|
||
|
<ul>
|
||
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
||
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
||
|
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
|
||
|
<li><a href="files.html"><span>Files</span></a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="tabs">
|
||
|
<ul>
|
||
|
<li><a href="annotated.html"><span>Class List</span></a></li>
|
||
|
<li><a href="functions.html"><span>Class Members</span></a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="navpath"><a class="el" href="namespacetthread.html">tthread</a>::<a class="el" href="classtthread_1_1condition__variable.html">condition_variable</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="contents">
|
||
|
<h1>condition_variable Class Reference</h1><!-- doxytag: class="tthread::condition_variable" -->
|
||
|
<p>Condition variable class.
|
||
|
<a href="#_details">More...</a></p>
|
||
|
|
||
|
<p><code>#include <<a class="el" href="tinythread_8h_source.html">tinythread.h</a>></code></p>
|
||
|
|
||
|
<p><a href="classtthread_1_1condition__variable-members.html">List of all members.</a></p>
|
||
|
<table border="0" cellpadding="0" cellspacing="0">
|
||
|
<tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
|
||
|
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9e62a1d1145c820a02469a48099fdfa9"></a><!-- doxytag: member="tthread::condition_variable::condition_variable" ref="a9e62a1d1145c820a02469a48099fdfa9" args="()" -->
|
||
|
</td><td class="memItemRight" valign="bottom"><a class="el" href="classtthread_1_1condition__variable.html#a9e62a1d1145c820a02469a48099fdfa9">condition_variable</a> ()</td></tr>
|
||
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <br/></td></tr>
|
||
|
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a58df09046f5006d4170ae92717f1e50b"></a><!-- doxytag: member="tthread::condition_variable::~condition_variable" ref="a58df09046f5006d4170ae92717f1e50b" args="()" -->
|
||
|
</td><td class="memItemRight" valign="bottom"><a class="el" href="classtthread_1_1condition__variable.html#a58df09046f5006d4170ae92717f1e50b">~condition_variable</a> ()</td></tr>
|
||
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <br/></td></tr>
|
||
|
<tr><td class="memTemplParams" colspan="2">template<class _mutexT > </td></tr>
|
||
|
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classtthread_1_1condition__variable.html#a4d877d804385bde4aacf2156e86faede">wait</a> (_mutexT &aMutex)</td></tr>
|
||
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Wait for the condition. <a href="#a4d877d804385bde4aacf2156e86faede"></a><br/></td></tr>
|
||
|
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classtthread_1_1condition__variable.html#a84c2ec0dd971c593883198a323eeb394">notify_one</a> ()</td></tr>
|
||
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Notify one thread that is waiting for the condition. <a href="#a84c2ec0dd971c593883198a323eeb394"></a><br/></td></tr>
|
||
|
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classtthread_1_1condition__variable.html#ad35a04e61229c15c5211ebff00089326">notify_all</a> ()</td></tr>
|
||
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Notify all threads that are waiting for the condition. <a href="#ad35a04e61229c15c5211ebff00089326"></a><br/></td></tr>
|
||
|
</table>
|
||
|
<hr/><a name="_details"></a><h2>Detailed Description</h2>
|
||
|
<p>Condition variable class. </p>
|
||
|
<p>This is a signalling object for synchronizing the execution flow for several threads. Example usage: </p>
|
||
|
<div class="fragment"><pre class="fragment"> <span class="comment">// Shared data and associated mutex and condition variable objects</span>
|
||
|
<span class="keywordtype">int</span> count;
|
||
|
mutex m;
|
||
|
<a class="code" href="classtthread_1_1condition__variable.html#a9e62a1d1145c820a02469a48099fdfa9" title="Constructor.">condition_variable</a> cond;
|
||
|
|
||
|
<span class="comment">// Wait for the counter to reach a certain number</span>
|
||
|
<span class="keywordtype">void</span> wait_counter(<span class="keywordtype">int</span> targetCount)
|
||
|
{
|
||
|
lock_guard<mutex> guard(m);
|
||
|
<span class="keywordflow">while</span>(count < targetCount)
|
||
|
cond.wait(m);
|
||
|
}
|
||
|
|
||
|
<span class="comment">// Increment the counter, and notify waiting threads</span>
|
||
|
<span class="keywordtype">void</span> increment()
|
||
|
{
|
||
|
lock_guard<mutex> guard(m);
|
||
|
++ count;
|
||
|
cond.notify_all();
|
||
|
}
|
||
|
</pre></div> <hr/><h2>Member Function Documentation</h2>
|
||
|
<a class="anchor" id="ad35a04e61229c15c5211ebff00089326"></a><!-- doxytag: member="tthread::condition_variable::notify_all" ref="ad35a04e61229c15c5211ebff00089326" args="()" -->
|
||
|
<div class="memitem">
|
||
|
<div class="memproto">
|
||
|
<table class="memname">
|
||
|
<tr>
|
||
|
<td class="memname">void notify_all </td>
|
||
|
<td>(</td>
|
||
|
<td class="paramname"></td>
|
||
|
<td> ) </td>
|
||
|
<td><code> [inline]</code></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class="memdoc">
|
||
|
|
||
|
<p>Notify all threads that are waiting for the condition. </p>
|
||
|
<p>All threads that are blocked waiting for this condition variable will be woken up. </p>
|
||
|
<dl class="note"><dt><b>Note:</b></dt><dd>Only threads that started waiting prior to this call will be woken up. </dd></dl>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<a class="anchor" id="a84c2ec0dd971c593883198a323eeb394"></a><!-- doxytag: member="tthread::condition_variable::notify_one" ref="a84c2ec0dd971c593883198a323eeb394" args="()" -->
|
||
|
<div class="memitem">
|
||
|
<div class="memproto">
|
||
|
<table class="memname">
|
||
|
<tr>
|
||
|
<td class="memname">void notify_one </td>
|
||
|
<td>(</td>
|
||
|
<td class="paramname"></td>
|
||
|
<td> ) </td>
|
||
|
<td><code> [inline]</code></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class="memdoc">
|
||
|
|
||
|
<p>Notify one thread that is waiting for the condition. </p>
|
||
|
<p>If at least one thread is blocked waiting for this condition variable, one will be woken up. </p>
|
||
|
<dl class="note"><dt><b>Note:</b></dt><dd>Only threads that started waiting prior to this call will be woken up. </dd></dl>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<a class="anchor" id="a4d877d804385bde4aacf2156e86faede"></a><!-- doxytag: member="tthread::condition_variable::wait" ref="a4d877d804385bde4aacf2156e86faede" args="(_mutexT &aMutex)" -->
|
||
|
<div class="memitem">
|
||
|
<div class="memproto">
|
||
|
<table class="memname">
|
||
|
<tr>
|
||
|
<td class="memname">void wait </td>
|
||
|
<td>(</td>
|
||
|
<td class="paramtype">_mutexT & </td>
|
||
|
<td class="paramname"> <em>aMutex</em></td>
|
||
|
<td> ) </td>
|
||
|
<td><code> [inline]</code></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class="memdoc">
|
||
|
|
||
|
<p>Wait for the condition. </p>
|
||
|
<p>The function will block the calling thread until the condition variable is woken by <code><a class="el" href="classtthread_1_1condition__variable.html#a84c2ec0dd971c593883198a323eeb394" title="Notify one thread that is waiting for the condition.">notify_one()</a></code>, <code><a class="el" href="classtthread_1_1condition__variable.html#ad35a04e61229c15c5211ebff00089326" title="Notify all threads that are waiting for the condition.">notify_all()</a></code> or a spurious wake up. </p>
|
||
|
<dl><dt><b>Parameters:</b></dt><dd>
|
||
|
<table border="0" cellspacing="2" cellpadding="0">
|
||
|
<tr><td valign="top"><tt>[in]</tt> </td><td valign="top"><em>aMutex</em> </td><td>A mutex that will be unlocked when the wait operation starts, an locked again as soon as the wait operation is finished. </td></tr>
|
||
|
</table>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<hr/>The documentation for this class was generated from the following file:<ul>
|
||
|
<li><a class="el" href="tinythread_8h_source.html">tinythread.h</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<hr class="footer"/><address style="text-align: right;"><small>Generated on Fri Oct 1 21:49:34 2010 for TinyThread++ by
|
||
|
<a href="http://www.doxygen.org/index.html">
|
||
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
|
||
|
</body>
|
||
|
</html>
|