A watcher is an object that gets created to record interest in some event.
For instance, the following code waits for
STDIN
to become readable:
<?php
// Wait until STDIN is readable
$w = new EvIo(STDIN, Ev::READ, function ($watcher, $revents) {
echo "STDIN is readable\n";
});
Ev::run(Ev::RUN_ONCE);
?>
Note that a watcher will automatically be stopped when the watcher object is
destroyed. Therefore, the watcher objects returned by the constructors or
factory methods should be kept.