<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.swoole-event.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'swoole-event.cycle.php',
    1 => 'Swoole\\Event::cycle',
    2 => 'Define a function to execute at the end of each event loop iteration',
  ),
  'up' => 
  array (
    0 => 'class.swoole-event.php',
    1 => 'Swoole\\Event',
  ),
  'prev' => 
  array (
    0 => 'swoole-event.add.php',
    1 => 'Swoole\\Event::add',
  ),
  'next' => 
  array (
    0 => 'swoole-event.defer.php',
    1 => 'Swoole\\Event::defer',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/swoole/swoole/event/cycle.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="swoole-event.cycle" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Swoole\Event::cycle</h1>
  <p class="verinfo">(No version information available, might only be in Git)</p><p class="refpurpose"><span class="refname">Swoole\Event::cycle</span> &mdash; <span class="dc-title">Define a function to execute at the end of each event loop iteration</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-swoole-event.cycle-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="modifier">function</span> <span class="methodname"><strong>Swoole\Event::cycle</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$before</code><span class="initializer"> = false</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="simpara">
   Defines a callback function to execute at the end (or beginning, if <code class="parameter">before</code> is true) of each event loop iteration.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-swoole-event.cycle-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">callback</code></dt>
    <dd>
     <p class="simpara">
      The function to execute. Set to <code class="literal">null</code> to clear a previously set cycle function.
     </p>
    </dd>
   
   
    <dt><code class="parameter">before</code></dt>
    <dd>
     <p class="simpara">
      If <code class="literal">true</code>, the callback executes before the event loop; if <code class="literal">false</code>, after.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-swoole-event.cycle-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="simpara">
   成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>， 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-swoole-event.cycle-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 Basic usage</strong></p>
    <div class="example-contents">
     <div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
Swoole\Timer</span><span style="color: #007700">::</span><span style="color: #0000BB">tick</span><span style="color: #007700">(</span><span style="color: #0000BB">2000</span><span style="color: #007700">, function (</span><span style="color: #0000BB">$id</span><span style="color: #007700">) {
    </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">);
});

</span><span style="color: #0000BB">Swoole\Event</span><span style="color: #007700">::</span><span style="color: #0000BB">cycle</span><span style="color: #007700">(function () {
    echo </span><span style="color: #DD0000">"hello [1]\n"</span><span style="color: #007700">;
    </span><span style="color: #0000BB">Swoole\Event</span><span style="color: #007700">::</span><span style="color: #0000BB">cycle</span><span style="color: #007700">(function () {
        echo </span><span style="color: #DD0000">"hello [2]\n"</span><span style="color: #007700">;
        </span><span style="color: #0000BB">Swoole\Event</span><span style="color: #007700">::</span><span style="color: #0000BB">cycle</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">);
    });
});

</span><span style="color: #0000BB">Swoole\Event</span><span style="color: #007700">::</span><span style="color: #0000BB">wait</span><span style="color: #007700">();</span></code></pre></div>
    </div>

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

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