Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 1574

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Watcher callbacks</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ev.watchers.html">Watchers</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ev.periodic-modes.html">Periodic watcher operation modes</a></div>
 <div class="up"><a href="book.ev.html">Ev</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="ev.watcher-callbacks" class="chapter">
 <h1>Watcher callbacks</h1>

 <p class="para">
  All watchers can be active(waiting for events) or inactive(paused). Only
  active watchers will have their callbacks invoked. All callbacks will be
  called with at least two arguments:
  <em><code class="parameter">watcher</code></em>
  - the watcher, and
  <em><code class="parameter">revents</code></em>
  a bitmask of received events.
 </p>
 <p class="para">
  Watcher callbacks are passed to the watcher contructors(the classes derived
  from
  <a href="class.evwatcher.html" class="classname">EvWatcher</a>
  -
   <span class="methodname"><a href="evcheck.construct.html" class="methodname">EvCheck::__construct()</a></span>
  ,
   <span class="methodname"><a href="evchild.construct.html" class="methodname">EvChild::__construct()</a></span>
  etc.). A watcher callback should match the following prototype:
 </p>
 <div class="methodsynopsis dc-description">
  <span class="type"><span class="type void">void</span></span>
   <span class="methodname"><strong>callback</strong></span>
   ([ <span class="methodparam">
   <span class="type">object</span>
    <code class="parameter">$watcher</code>
   <span class="initializer"> = NULL</span>
  </span>
  [, <span class="methodparam">
   <span class="type">int</span>
    <code class="parameter">$revents</code>
   <span class="initializer"> = NULL</span>
  </span>
 ]] )</div>

 <p class="para">
  <dl>

   <dt>

    <span class="term">
     <em><code class="parameter">watcher</code></em>
    </span>
    <dd>

     <p class="para">
      The watcher instance(of a class extending
      <a href="class.evwatcher.html" class="classname">EvWatcher</a>
      ).
     </p>
    </dd>

   </dt>

   <dt>

    <span class="term">
     <em><code class="parameter">revents</code></em>
    </span>
    <dd>

     <p class="para">
      <a href="class.ev.html#ev.constants.watcher-revents" class="link">Watcher received events</a>
      .
     </p>
    </dd>

   </dt>

  </dl>

 </p>
 <p class="para">
  Each watcher type has its associated bit in
  <em><code class="parameter">revents</code></em>
  , so one can use the same callback for multiple watchers. The event mask is
  named after the type, i.e.
  <a href="class.evchild.html" class="classname">EvChild</a>
  (or
   <span class="methodname"><a href="evloop.child.html" class="methodname">EvLoop::child()</a></span>
  ) sets
  <strong><code>EV::CHILD</code></strong>
  ,
  <a href="class.evprepare.html" class="classname">EvPrepare</a>
  (or
   <span class="methodname"><a href="evloop.prepare.html" class="methodname">EvLoop::prepare()</a></span>
  ) sets
  <strong><code>Ev::PREPARE</code></strong>
  ,
  <a href="class.evperiodic.html" class="classname">EvPeriodic</a>
  (or
   <span class="methodname"><a href="evloop.periodic.html" class="methodname">EvLoop::periodic()</a></span>
  ) sets
  <strong><code>Ev::PERIODIC</code></strong>
  and so on, with the exception of I/O events (which can set both
  <strong><code>Ev::READ</code></strong>
  and
  <strong><code>Ev::WRITE</code></strong>
  bits).
 </p>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ev.watchers.html">Watchers</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ev.periodic-modes.html">Periodic watcher operation modes</a></div>
 <div class="up"><a href="book.ev.html">Ev</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>