Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 111

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>GNU CommonC++: ost::Conditional Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li id="current"><a href="classes.html"><span>Classes</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
    <li><a href="examples.html"><span>Examples</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="classes.html"><span>Alphabetical&nbsp;List</span></a></li>
    <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
    <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
    <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
  </ul></div>
<div class="nav">
<a class="el" href="namespaceost.html">ost</a>::<a class="el" href="classost_1_1_conditional.html">Conditional</a></div>
<h1>ost::Conditional Class Reference</h1><!-- doxytag: class="ost::Conditional" -->A conditional variable synchcronization object for one to one and one to many signal and control events between processes.conditional.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="thread_8h-source.html">thread.h</a>&gt;</code>
<p>
<p>Inheritance diagram for ost::Conditional:
<p><center><img src="classost_1_1_conditional.png" usemap="#ost::Conditional_map" border="0" alt=""></center>
<map name="ost::Conditional_map">
<area href="classost_1_1_buffer.html" alt="ost::Buffer" shape="rect" coords="0,56,100,80">
<area href="classost_1_1_fixed_buffer.html" alt="ost::FixedBuffer" shape="rect" coords="0,112,100,136">
</map>
<a href="classost_1_1_conditional-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#7d7009cab2b814c82b41d8682a6ebff0">Conditional</a> (const char *id=NULL)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create an instance of a conditional.  <a href="#7d7009cab2b814c82b41d8682a6ebff0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#9772a4c8e522a010a37c63c5ee078384">~Conditional</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destroy the conditional.  <a href="#9772a4c8e522a010a37c63c5ee078384"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#80822e8493bafb68bac637bbf5fe772d">signal</a> (bool broadcast)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Signal a conditional object and a waiting threads.  <a href="#80822e8493bafb68bac637bbf5fe772d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#2cac07a385596391b0fc8c15b8a598e5">wait</a> (<a class="el" href="thread_8h.html#f412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timer=0, bool locked=false)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Wait to be signaled from another thread.  <a href="#2cac07a385596391b0fc8c15b8a598e5"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#e3fd225eeae79c24eb7f521f285e8289">enterMutex</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Locks the conditional's mutex for this thread.  <a href="#e3fd225eeae79c24eb7f521f285e8289"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#2a3bf89c582dad8ba7e81370fd361668">lock</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">In the future we will use lock in place of enterMutex since the conditional composite is not a recursive mutex, and hence using enterMutex may cause confusion in expectation with the behavior of the <a class="el" href="classost_1_1_mutex.html">Mutex</a> class.  <a href="#2a3bf89c582dad8ba7e81370fd361668"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#dcd3f704ef27fff5501a42185a09471f">tryEnterMutex</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Tries to lock the conditional for the current thread.  <a href="#dcd3f704ef27fff5501a42185a09471f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#507839fac82a32f946fa5f87d41bef28">test</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#cc29112f68c34a9844b3c3dad0d03603">leaveMutex</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Leaving a mutex frees that mutex for use by another thread.  <a href="#cc29112f68c34a9844b3c3dad0d03603"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_conditional.html#8b6126bbb6e58c1b8ef937bebf4af222">unlock</a> (void)</td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A conditional variable synchcronization object for one to one and one to many signal and control events between processes.conditional. 
<p>
<a class="el" href="classost_1_1_conditional.html">Conditional</a> variables may wait for and receive signals to notify when to resume or perform operations. Multiple waiting threads may be woken with a broadcast signal.<p>
<dl compact><dt><b>Warning:</b></dt><dd>While this class inherits from <a class="el" href="classost_1_1_mutex.html">Mutex</a>, the methods of the class <a class="el" href="classost_1_1_conditional.html">Conditional</a> just handle the system conditional variable, so the user is responsible for calling enterMutex and leaveMutex so as to avoid race conditions. Another thing to note is that if you have several threads waiting on one condition, not uncommon in thread pools, each thread must take care to manually unlock the mutex if cancellation occurs. Otherwise the first thread cancelled will deadlock the rest of the thread.</dd></dl>
<dl compact><dt><b>Author:</b></dt><dd>David Sugar </dd></dl>
<dl compact><dt><b><a class="el" href="todo.html#_todo000004">Todo:</a></b></dt><dd>implement in win32 </dd></dl>

<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="7d7009cab2b814c82b41d8682a6ebff0"></a><!-- doxytag: member="ost::Conditional::Conditional" ref="7d7009cab2b814c82b41d8682a6ebff0" args="(const char *id=NULL)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">ost::Conditional::Conditional           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const char *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>id</em> = <code>NULL</code>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Create an instance of a conditional. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>id</em>&nbsp;</td><td>name of conditional, optional for deadlock testing. </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="9772a4c8e522a010a37c63c5ee078384"></a><!-- doxytag: member="ost::Conditional::~Conditional" ref="9772a4c8e522a010a37c63c5ee078384" args="()" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">virtual ost::Conditional::~Conditional           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [virtual]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Destroy the conditional. 
<p>
    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="e3fd225eeae79c24eb7f521f285e8289"></a><!-- doxytag: member="ost::Conditional::enterMutex" ref="e3fd225eeae79c24eb7f521f285e8289" args="(void)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void ost::Conditional::enterMutex           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Locks the conditional's mutex for this thread. 
<p>
Remember that Conditional's mutex is NOT a recursive mutex!<p>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="classost_1_1_conditional.html#cc29112f68c34a9844b3c3dad0d03603">leaveMutex</a> </dd></dl>
    </td>
  </tr>
</table>
<a class="anchor" name="cc29112f68c34a9844b3c3dad0d03603"></a><!-- doxytag: member="ost::Conditional::leaveMutex" ref="cc29112f68c34a9844b3c3dad0d03603" args="(void)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void ost::Conditional::leaveMutex           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Leaving a mutex frees that mutex for use by another thread. 
<p>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="classost_1_1_conditional.html#e3fd225eeae79c24eb7f521f285e8289">enterMutex</a> </dd></dl>
    </td>
  </tr>
</table>
<a class="anchor" name="2a3bf89c582dad8ba7e81370fd361668"></a><!-- doxytag: member="ost::Conditional::lock" ref="2a3bf89c582dad8ba7e81370fd361668" args="(void)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void ost::Conditional::lock           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
In the future we will use lock in place of enterMutex since the conditional composite is not a recursive mutex, and hence using enterMutex may cause confusion in expectation with the behavior of the <a class="el" href="classost_1_1_mutex.html">Mutex</a> class. 
<p>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="classost_1_1_conditional.html#e3fd225eeae79c24eb7f521f285e8289">enterMutex</a> </dd></dl>
    </td>
  </tr>
</table>
<a class="anchor" name="80822e8493bafb68bac637bbf5fe772d"></a><!-- doxytag: member="ost::Conditional::signal" ref="80822e8493bafb68bac637bbf5fe772d" args="(bool broadcast)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void ost::Conditional::signal           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">bool&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>broadcast</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Signal a conditional object and a waiting threads. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>broadcast</em>&nbsp;</td><td>this signal to all waiting threads if true. </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="507839fac82a32f946fa5f87d41bef28"></a><!-- doxytag: member="ost::Conditional::test" ref="507839fac82a32f946fa5f87d41bef28" args="(void)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">bool ost::Conditional::test           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
    </td>
  </tr>
</table>
<a class="anchor" name="dcd3f704ef27fff5501a42185a09471f"></a><!-- doxytag: member="ost::Conditional::tryEnterMutex" ref="dcd3f704ef27fff5501a42185a09471f" args="(void)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">bool ost::Conditional::tryEnterMutex           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Tries to lock the conditional for the current thread. 
<p>
Behaves like <a class="el" href="classost_1_1_conditional.html#e3fd225eeae79c24eb7f521f285e8289">enterMutex</a> , except that it doesn't block the calling thread.<p>
<dl compact><dt><b>Returns:</b></dt><dd>true if locking the mutex was succesful otherwise false</dd></dl>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="classost_1_1_conditional.html#e3fd225eeae79c24eb7f521f285e8289">enterMutex</a> <p>
<a class="el" href="classost_1_1_conditional.html#cc29112f68c34a9844b3c3dad0d03603">leaveMutex</a> </dd></dl>
    </td>
  </tr>
</table>
<a class="anchor" name="8b6126bbb6e58c1b8ef937bebf4af222"></a><!-- doxytag: member="ost::Conditional::unlock" ref="8b6126bbb6e58c1b8ef937bebf4af222" args="(void)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void ost::Conditional::unlock           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
    </td>
  </tr>
</table>
<a class="anchor" name="2cac07a385596391b0fc8c15b8a598e5"></a><!-- doxytag: member="ost::Conditional::wait" ref="2cac07a385596391b0fc8c15b8a598e5" args="(timeout_t timer=0, bool locked=false)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">bool ost::Conditional::wait           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="thread_8h.html#f412159e5cef839836a5e7b19ee75d1c">timeout_t</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>timer</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>bool&nbsp;</td>
          <td class="mdname" nowrap> <em>locked</em> = <code>false</code></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Wait to be signaled from another thread. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>timer</em>&nbsp;</td><td>time period to wait. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>locked</em>&nbsp;</td><td>flag if already locked the mutex. </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="thread_8h-source.html">thread.h</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Mon Jun 19 10:50:57 2006 for GNU CommonC++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>