php-doc-en/reference/ev/watchers.xml
TAKAGI Masahiro ef70e0157e Add Revision tag
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328943 c90b9560-bf6c-de11-be94-00142212c4b1
2013-01-01 07:37:13 +00:00

67 lines
1.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="ev.watchers" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Watchers</title>
<para>
A watcher is an object that gets created to record interest in some event.
For instance, the following code waits for
<constant>STDIN</constant>
to become readable:
<programlisting role="php">
<![CDATA[
<?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);
?>
]]>
</programlisting>
</para>
<para>
All the watcher constructors automatically start the watchers.
<literal>createStopped</literal>
methods create stopped watchers(e.g.
<methodname>EvIo::createStopped</methodname>
)
</para>
<para>
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.
</para>
<para>
Note also that all methods changing some watcher property(
<emphasis>set</emphasis>
,
<varname>priority</varname>
etc.) automatically stop and start it again if it is active, which means
pending events get lost.
</para>
<para>
See also:
<link linkend="ev.watcher-callbacks">Watcher callbacks</link>
.
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->