array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'evwatcher.keepalive.php', 1 => 'EvWatcher::keepalive', 2 => 'Configures whether to keep the loop from returning', ), 'up' => array ( 0 => 'class.evwatcher.php', 1 => 'EvWatcher', ), 'prev' => array ( 0 => 'evwatcher.invoke.php', 1 => 'EvWatcher::invoke', ), 'next' => array ( 0 => 'evwatcher.setcallback.php', 1 => 'EvWatcher::setCallback', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/ev/evwatcher/keepalive.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PECL ev >= 0.2.0)
EvWatcher::keepalive — Configures whether to keep the loop from returning
   Configures whether to keep the loop from returning. With keepalive
   value
   set to false the watcher won't keep
   Ev::run()
   /
   EvLoop::run()
   from returning even though the watcher is active.
  
   Watchers have keepalive
   value
   true by default.
  
Clearing keepalive status is useful when returning from Ev::run() / EvLoop::run() just because of the watcher is undesirable. It could be a long running UDP socket watcher or so.
value
    
      With keepalive
      value
      set to false the watcher won't keep
      Ev::run()
      /
      EvLoop::run()
      from returning even though the watcher is active.
     
Returns the previous state.
示例 #1 Register an I/O watcher for some UDP socket but do not keep the event loop from running just because of that watcher.
<?php
$udp_socket = ...
$udp_watcher = new EvIo($udp_socket, Ev::READ, function () { /* ... */ });
$udp_watcher->keepalive(FALSE);
?>