array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'es', ), 'this' => array ( 0 => 'ev.watcher-callbacks.php', 1 => 'Watcher callbacks', ), 'up' => array ( 0 => 'book.ev.php', 1 => 'Ev', ), 'prev' => array ( 0 => 'ev.watchers.php', 1 => 'Watchers', ), 'next' => array ( 0 => 'ev.periodic-modes.php', 1 => 'Periodic watcher operation modes', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/ev/watcher-callbacks.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
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:
watcher
- the watcher, and
revents
a bitmask of received events.
Watcher callbacks are passed to the watcher constructors (the classes derived from EvWatcher - EvCheck::__construct() , EvChild::__construct() etc.). A watcher callback should match the following prototype:
watcher
The watcher instance(of a class extending EvWatcher ).
revents
Each watcher type has its associated bit in
revents
, so one can use the same callback for multiple watchers. The event mask is
named after the type, i.e.
EvChild
(or
EvLoop::child()
) sets
EV::CHILD
,
EvPrepare
(or
EvLoop::prepare()
) sets
Ev::PREPARE
,
EvPeriodic
(or
EvLoop::periodic()
) sets
Ev::PERIODIC
and so on, with the exception of I/O events (which can set both
Ev::READ
and
Ev::WRITE
bits).