Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > f448deafa1de20c56618e7ac9c6ef5d7 > files > 116

Falcon-doc-0.9.6.6-1.fc14.noarch.rpm

<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>Class SyncCounter - Class SyncCounter</title>
   <link href="faldoc.css" rel="stylesheet" type="text/css"/>
   <link href="tabs.css" rel="stylesheet" type="text/css"/>
</head>
<body class="faldoc_body">
<div class="navitop">
   <div class="tabs">
      <ul>
         <li><a href="./index.html"><span>Main</span></a></li>
         <li><a href="./modules.html"><span>Modules</span></a></li>
         <li><a href="./pages.html"><span>Related pages</span></a></li>
         <li><a href="./groups.html"><span>Groups</span></a></li>
         <li><a href="./classes.html"><span>Classes</span></a></li>
         <li><a href="./objects.html"><span>Objects</span></a></li>
         <li><a href="./functions.html"><span>All functions</span></a></li>
         <li><a href="./enum.html"><span>Enumerations</span></a></li>
         
      </ul>
   </div>
</div>
<hr/>

<h1 class="faldoc_title">Class SyncCounter<span class="faldoc_belong"><a href="./module_feathers_threading.html">[in Threading]</a></p></h1>

<p class="faldoc_brief">Implements a synchronization counter (semaphore). </p>
<p class="faldoc_funcdecl">
<b>class</b> SyncCounter( [count] )
</p>


   <p class="faldoc_brief"><a href="#more">more...</a></p>
   <h2 class="faldoc_title">Summary</h2>
   <table class="faldoc_list">
   
      
         <tr><td><a href="#post">post()</a></td><td>Releases the counter or increases the counter by more than one. </td></tr>
      
   
   </table>







<a name="more"><h2 class="faldoc_title">Detailed description</h2></a>

<p class="faldoc_funcdecl">
<b>class</b> SyncCounter( [count] )
</p>
<table class="faldoc_function">

<tr><td class="faldoc_optparam">count</td><td class="faldoc_optparamdesc">Initial counter value (defaults to 0). </td></tr>
</table>
<br/>
<p class="item_brief">Implements a synchronization counter (semaphore). </p>
<p class="faldoc_text">This class implements a synchronization counter, commonly known as "semaphore", which provides the following behavior: </p>
<ul>
<li>If the counter is greater than zero, the item can be acquired, and the counter is atomically decremented. </li><li>If the counter is zero, the acquiring thread must wait for the counter to become greater than zero. </li><li>The release operation increments the counter and eventually wakes up waiting threads. </li><li> The counter provides also a <a href="./class_SyncCounter.html#post">SyncCounter.post</a> method which may increase the counter of more than one unit (allowing the structure to be acquired by more than one thread). </li>
</ul>
<p class="faldoc_text"> We have adopted the "counter" name rather than the more common "semaphore" to avoid confusion with the Semaphore class used for coroutines, and also because the <b>post</b> semantic is merged with the <b>release</b> method. </p>
<p class="faldoc_text"> The counter is created with an initial count that defaults to zero; this means that the first thread trying to acquire this structure will block until a <b>post</b> or <b>release</b> is issued. </p>
<p class="faldoc_text"> If a positive interger is given as <b>count</b>, then the same amount of threads will be able to acquire the semaphore before one thread being blocked. </p>




   <h2 class="faldoc_title">Methods</h2>
   
      <h3 class="faldoc_funcname"><a name="post">post()</a></h3>
      <p class="item_brief">Releases the counter or increases the counter by more than one. </p>
      <p class="faldoc_funcdecl">SyncCounter.post( [count] )</p>
      
         <table class="faldoc_function">
         
         <tr><td class="faldoc_optparam">count</td><td class="faldoc_optparamdesc">The number of signals to be posted to this semaphore. </td></tr>
         
         
         </table>
      
      <p class="faldoc_text"><p class="faldoc_text">This method acts as release(), but it can be provided an optional parameter to give more than one thread the ability to acquire this structure. </p>
<p class="faldoc_text">It is not possible to use this method to reduce the internal count. </p>
</p>
   

<hr/>
<div class="navibottom">
   <center>
      <a href="./index.html">Main</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="./modules.html">Modules</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="./pages.html">Related pages</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="./groups.html">Groups</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="./classes.html">Classes</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="./objects.html">Objects</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="./functions.html">All functions</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="./enum.html">Enumerations</a>
   </center>
</div>
</div>
<div class="faldoc_signature">Made with <a href="http://www.falconpl.org">faldoc 2.2.0</div>
</body>
</html>