Sophie

Sophie

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

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>Watchers</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ev.examples.html">Examples</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ev.watcher-callbacks.html">Watcher callbacks</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.watchers" class="chapter">
 <h1>Watchers</h1>

 <p class="para">
  A watcher is an object that gets created to record interest in some event.
  For instance, the following code waits for
  <strong><code>STDIN</code></strong>
  to become readable:
  <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Wait&nbsp;until&nbsp;STDIN&nbsp;is&nbsp;readable<br /></span><span style="color: #0000BB">$w&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">EvIo</span><span style="color: #007700">(</span><span style="color: #0000BB">STDIN</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Ev</span><span style="color: #007700">::</span><span style="color: #0000BB">READ</span><span style="color: #007700">,&nbsp;function&nbsp;(</span><span style="color: #0000BB">$watcher</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$revents</span><span style="color: #007700">)&nbsp;{<br />&nbsp;echo&nbsp;</span><span style="color: #DD0000">"STDIN&nbsp;is&nbsp;readable\n"</span><span style="color: #007700">;<br />});<br /></span><span style="color: #0000BB">Ev</span><span style="color: #007700">::</span><span style="color: #0000BB">run</span><span style="color: #007700">(</span><span style="color: #0000BB">Ev</span><span style="color: #007700">::</span><span style="color: #0000BB">RUN_ONCE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
  </div>

 </p>
 <p class="para">
  All the watcher constructors automatically start the watchers.
  <em>createStopped</em>
  methods create stopped watchers(e.g.
   <span class="methodname"><a href="evio.createstopped.html" class="methodname">EvIo::createStopped()</a></span>
  )
 </p>
 <p class="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.
 </p>
 <p class="para">
  Note also that all methods changing some watcher property(
  <em class="emphasis">set</em>
  ,
  <var class="varname"><var class="varname">priority</var></var>
  etc.) automatically stop and start it again if it is active, which means
  pending events get lost.
 </p>
 <p class="para">
  See also:
  <a href="ev.watcher-callbacks.html" class="link">Watcher callbacks</a>
  .
 </p>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ev.examples.html">Examples</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ev.watcher-callbacks.html">Watcher callbacks</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>