<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.event.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'event.callbacks.php',
    1 => 'Event callbacks',
    2 => 'Event callbacks',
  ),
  'up' => 
  array (
    0 => 'book.event.php',
    1 => 'Event',
  ),
  'prev' => 
  array (
    0 => 'event.persistence.php',
    1 => 'About event persistence',
  ),
  'next' => 
  array (
    0 => 'event.constructing.signal.events.php',
    1 => 'Constructing signal events',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/event/event.callbacks.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="event.callbacks" class="chapter">
 <h1 class="title">Event callbacks</h1>

 <p class="para">
  If a callback is registered for an event, it will be called when the event
  becomes active. To associate a callback with event one can pass a
  <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span>
  to either
  <span class="methodname"><a href="event.construct.php" class="methodname">Event::__construct()</a></span>,
  or
  <span class="methodname"><a href="event.set.php" class="methodname">Event::set()</a></span>,
  or one of the factory methods like
  <span class="methodname"><a href="event.timer.php" class="methodname">Event::timer()</a></span>.
 </p>
 <p class="para">
  An event callback should match the following prototype:
 </p>
 <div class="methodsynopsis dc-description"><span class="methodname"><strong>callback</strong></span>(<span class="methodparam">
   
   <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$fd</code>
   <span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span>
  </span>, <span class="methodparam">
   
   <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$what</code>
  <span class="initializer"> = ?</span></span>, <span class="methodparam">
   
   <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$arg</code>
   <span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span>
  </span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

 <dl>
  
   <dt>
    <code class="parameter">fd</code>
   </dt>
   <dd>
    <p class="para">
     The file descriptor, stream resource or socket associated with the
     event. For signal event
     <code class="parameter">fd</code>
     is equal to the signal number.
    </p>
   </dd>
  
  
   <dt>
    <code class="parameter">what</code>
   </dt>
   <dd>
    <p class="para">
     Bit mask of
     <em>all</em>
     events triggered.
    </p>
   </dd>
  
  
   <dt>
    <code class="parameter">arg</code>
   </dt>
   <dd>
    <p class="para">
     User custom data.
    </p>
   </dd>
  
 </dl>
 <p class="para">
  <span class="methodname"><a href="event.timer.php" class="methodname">Event::timer()</a></span>
  expects the callback to match the following prototype:
 </p>
 <div class="methodsynopsis dc-description"><span class="methodname"><strong>callback</strong></span>(<span class="methodparam">
   
   <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$arg</code>
   <span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span>
  </span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

 <dl>
  
   <dt>
    <code class="parameter">arg</code>
   </dt>
   <dd>
    <p class="para">
     User custom data.
    </p>
   </dd>
  
 </dl>
 <p class="para">
  <span class="methodname"><a href="event.signal.php" class="methodname">Event::signal()</a></span>
  expects the callback to match the following prototype:
 </p>
 <div class="methodsynopsis dc-description"><span class="methodname"><strong>callback</strong></span>(<span class="methodparam">
   
   <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$signum</code>
  <span class="initializer"> = ?</span></span>, <span class="methodparam">
   
   <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$arg</code>
   <span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span>
  </span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

 <dl>
  
   <dt>
    <code class="parameter">signum</code>
   </dt>
   <dd>
    <p class="para">
     The number of the triggered signal(e.g.
     <strong><code><a href="pcntl.constants.php#constant.sigterm">SIGTERM</a></code></strong>
     ).
    </p>
   </dd>
  
  
   <dt>
    <code class="parameter">arg</code>
   </dt>
   <dd>
    <p class="para">
     User custom data.
    </p>
   </dd>
  
 </dl>
</div>
<?php manual_footer($setup); ?>