<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.pool.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'pool.collect.php',
    1 => 'Pool::collect',
    2 => 'Collect references to completed tasks',
  ),
  'up' => 
  array (
    0 => 'class.pool.php',
    1 => 'Pool',
  ),
  'prev' => 
  array (
    0 => 'class.pool.php',
    1 => 'Pool',
  ),
  'next' => 
  array (
    0 => 'pool.construct.php',
    1 => 'Pool::__construct',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pthreads/pool/collect.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="pool.collect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Pool::collect</h1>
  <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Pool::collect</span> &mdash; <span class="dc-title">Collect references to completed tasks</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-pool.collect-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Pool::collect</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type Callable">Callable</a></span> <code class="parameter">$collector</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   Allows the pool to collect references determined to be garbage by the
   optionally given collector.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-pool.collect-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">collector</code></dt>
    <dd>
     <p class="para">
      A Callable collector that returns a boolean on whether the task can be
      collected or not. Only in rare cases should a custom collector need to
      be used.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-pool.collect-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   The number of remaining tasks in the pool to be collected.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-pool.collect-changelog">
  <h3 class="title">Журнал змін</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Версія</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL pthreads 3.0.0</td>
       <td>
        An integer is now returned, and the <code class="parameter">collector</code>
        parameter is now optional.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-pool.collect-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 A basic example of <span class="methodname"><strong>Pool::collect()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$pool </span><span style="color: #007700">= new </span><span style="color: #0000BB">Pool</span><span style="color: #007700">(</span><span style="color: #0000BB">4</span><span style="color: #007700">);<br /><br />for (</span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i </span><span style="color: #007700">&lt; </span><span style="color: #0000BB">15</span><span style="color: #007700">; ++</span><span style="color: #0000BB">$i</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">submit</span><span style="color: #007700">(new class extends </span><span style="color: #0000BB">Threaded </span><span style="color: #007700">{});<br />}<br /><br />while (</span><span style="color: #0000BB">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">collect</span><span style="color: #007700">()); </span><span style="color: #FF8000">// blocks until all tasks have finished executing<br /><br /></span><span style="color: #0000BB">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">shutdown</span><span style="color: #007700">();</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


</div><?php manual_footer($setup); ?>