Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 4fccfe23f6486142b4197d1daac0cf21 > files > 92

Falcon-doc-0.9.6.6-2.fc15.noarch.rpm

<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>Class Barrier - Class Barrier</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 Barrier<span class="faldoc_belong"><a href="./module_feathers_threading.html">[in Threading]</a></p></h1>

<p class="faldoc_brief">Gate controlling the transit of threads for certain operations. </p>
<p class="faldoc_funcdecl">
<b>class</b> Barrier( [mode] ) \
      <b>from</b> <a href="./class_Waitable.html">Waitable</a>
</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="#close">close()</a></td><td>Closes the barrier. </td></tr>
      
         <tr><td><a href="#open">open()</a></td><td>Opens the barrier. </td></tr>
      
   
   </table>





   <h3 class="faldoc_title">Inherited methods</h3>
   <table class="faldoc_list">
   
      <tr><td><a href="./class_Waitable.html#release">release</a> from Waitable&nbsp;</td><td>Releases a structure acquired by a waiting function. </td></tr>
   
   </table>



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

<p class="faldoc_funcdecl">
<b>class</b> Barrier( [mode] ) \
      <b>from</b> <a href="./class_Waitable.html">Waitable</a>
</p>
<table class="faldoc_function">

<tr><td class="faldoc_optparam">mode</td><td class="faldoc_optparamdesc">Set to true to initialize the barrier to open. </td></tr>
</table>
<br/>
<p class="item_brief">Gate controlling the transit of threads for certain operations. </p>
<p class="faldoc_text">The Barrier synchronization structure is a structure that can be either acquired by all or none of the threads willing to acquire it. If the barrier is open, then any wait on it will cause the calling thread to acquire it and proceed immediately, while if it's closed the waiting threads will be blocked forever, until the barrier gets open from the outside. </p>
<p class="faldoc_text"> The methods <b>open</b> and <b>close</b> control the behavior of the barrier. </p>
<p class="faldoc_text">One use for the barriers is that of communicating a pool of threads a kind termination request; by sharing the barrier with all the threads in the pool, a controlling thread may control their behavior; if they wait on the barrier and on other resources, when the barrier is open they will acquire it, and in this way they will know that is time for a clean termination: </p>
<pre class="faldoc_code">
   class AThread( struct, bar ) from Thread
      bar = bar
      struct = struct
      ...
      function run()
         loop
            acquired = self.wait( self.bar, self.struct )
            if acquired == self.bar
               // end...
               return nil
            end

            //... work on self.struct
         end
      end
   end
</pre>
<p class="faldoc_text">Release is a no-op for a barrier. </p>
<p class="faldoc_note"><span class="faldoc_notetype">Note:</span>  By default, the barrier is created in closed status. To create it in open status, pass the <b>mode</b> parameter as a true value. </p>




   <h2 class="faldoc_title">Methods</h2>
   
      <h3 class="faldoc_funcname"><a name="close">close()</a></h3>
      <p class="item_brief">Closes the barrier. </p>
      <p class="faldoc_funcdecl">Barrier.close( )</p>
      
      <p class="faldoc_text"><p class="faldoc_text">Prevents any thread to acquire the barrier. From this moment on, all the threads trying to wait on this barrier will block. </p>
</p>
   
      <h3 class="faldoc_funcname"><a name="open">open()</a></h3>
      <p class="item_brief">Opens the barrier. </p>
      <p class="faldoc_funcdecl">Barrier.open( )</p>
      
      <p class="faldoc_text"><p class="faldoc_text">Allow all the waiting threads to pass through the barrier. </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>