Sophie

Sophie

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

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 Semaphore - Class Semaphore</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="./pages.html"><span>Related pages</span></a></li>
         <li><a href="./groups.html"><span>Groups</span></a></li>
         <li><a href="./funset.html"><span>Function sets</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="./globals.html"><span>Globals</span></a></li>
         
      </ul>
   </div>
</div>
<hr/>

<h1 class="faldoc_title">Class Semaphore</h1>

<p class="faldoc_brief">Simple coroutine synchronization device. </p>
<p class="faldoc_funcdecl">
<b>class</b> Semaphore( [initValue] )
</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>Increments the count of the semaphore. </td></tr>
      
         <tr><td><a href="#wait">wait()</a></td><td>Waits on a semaphore. </td></tr>
      
   
   </table>







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

<p class="faldoc_funcdecl">
<b>class</b> Semaphore( [initValue] )
</p>
<table class="faldoc_function">

<tr><td class="faldoc_optparam">initValue</td><td class="faldoc_optparamdesc">Initial value for the semaphore; if not given, 0 will be assumed. </td></tr>
</table>
<br/>
<p class="item_brief">Simple coroutine synchronization device. </p>
<p class="faldoc_text">The semaphore is a simple synchronization object that is used by coroutines to communicate each others about relevant changes in the status of the application. </p>
<p class="faldoc_text"> Decrements the value of the semaphore, and eventually waits for the value to be > 0. When a <a href="./class_Semaphore.html#wait">Semaphore.wait</a> method is called on a semaphore, two things may happen: if the value of the semaphore is greater than zero, the value is decremented and the coroutine can proceed. If it's zero, the coroutine is swapped out until the semaphore gets greater than zero again. When this happens, the coroutine decrements the value of the semaphore and proceeds. If a timeout parameter is given, in case the semaphore wasn't posted before the given timeout the function will return false. </p>
<p class="faldoc_text"> The order by which coroutines are resumed is the same by which they asked to wait on a semaphore. In this sense, <a href="./class_Semaphore.html#wait">Semaphore.wait</a> method is implemented as a fair wait routine. </p>
<p class="faldoc_text"> The <a href="./class_Semaphore.html#post">Semaphore.post</a> method will raise the count of the semaphore by the given parameter (1 is the default if the parameter is not given). However, the calling coroutine won't necessarily be swapped out until a <a href="./functions.html#yield">yield</a> is called. </p>
<p class="faldoc_text"> By default, the semaphore is initialized to zero; this means that the first wait will block the waiting coroutine, unless a <a href="./class_Semaphore.html#post">Semaphore.post</a> is issued first. </p>




   <h2 class="faldoc_title">Methods</h2>
   
      <h3 class="faldoc_funcname"><a name="post">post()</a></h3>
      <p class="item_brief">Increments the count of the semaphore. </p>
      <p class="faldoc_funcdecl">Semaphore.post( [count] )</p>
      
         <table class="faldoc_function">
         
         <tr><td class="faldoc_optparam">count</td><td class="faldoc_optparamdesc">The amount by which the semaphore will be incremented (1 by default). </td></tr>
         
         
         </table>
      
      <p class="faldoc_text"><p class="faldoc_text">This method will increment the count of the semaphore by 1 or by a specified amount, allowing the same number of waiting coroutines to proceed. </p>
<p class="faldoc_text"> However, the calling coroutine won't necessarily be swapped out until a <a href="./functions.html#yield">yield</a> is called. </p>
</p>
   
      <h3 class="faldoc_funcname"><a name="wait">wait()</a></h3>
      <p class="item_brief">Waits on a semaphore. </p>
      <p class="faldoc_funcdecl">Semaphore.wait( [timeout] )</p>
      
         <table class="faldoc_function">
         
         <tr><td class="faldoc_optparam">timeout</td><td class="faldoc_optparamdesc">Optional maximum wait in seconds. </td></tr>
         
         
         </table>
      
      <p class="faldoc_text"><p class="faldoc_text">Decrements the value of the semaphore, and eventually waits for the value to be greater than zero. </p>
</p>
   

<hr/>
<div class="navibottom">
   <center>
      <a href="./index.html">Main</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="./funset.html">Function sets</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="./globals.html">Globals</a>
   </center>
</div>
</div>
<div class="faldoc_signature">Made with <a href="http://www.falconpl.org">faldoc 2.2.0</div>
</body>
</html>