首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

EvLoop (class)

Introduction

(PECL ev >= 0.2.0)

Represents an event loop that is always distinct from the default loop . Unlike the default loop , it cannot handle EvChild watchers.

Having threads we have to create a loop per thread, and use the default loop in the parent thread.

The default event loop is initialized automatically by Ev . It is accessible via methods of the Ev class, or via EvLoop::defaultLoop() method.

Class synopsis

final EvLoop {

/* Properties */

public $data ;

public $backend ;

public $is_default_loop ;

public $iteration ;

public $pending ;

public $io_interval ;

public $timeout_interval ;

public $depth ;

/* Methods */

代码语言:javascript
复制
public int backend ( void )
代码语言:javascript
复制
final public EvCheck check (  string $callback  [,  string $data  [,  string $priority  ]] )
代码语言:javascript
复制
final public EvChild child (  string $pid  ,  string $trace  ,  string $callback  [,  string $data  [,  string $priority  ]] )
代码语言:javascript
复制
public __construct ([  int $flags  [,  mixed $data  = NULL  [,  double $io_interval  = 0.0  [,  double $timeout_interval  = 0.0  ]]]] )
代码语言:javascript
复制
public static EvLoop defaultLoop ([  int $flags  = Ev::FLAG_AUTO  [,  mixed $data  = NULL  [,  double $io_interval  = 0.  [,  double $timeout_interval  = 0.  ]]]] )
代码语言:javascript
复制
final public EvEmbed embed (  string $other  [,  string $callback  [,  string $data  [,  string $priority  ]]] )
代码语言:javascript
复制
final public EvFork fork (  callable $callback  [,  mixed $data  = NULL  [,  int $priority  = 0  ]] )
代码语言:javascript
复制
final public EvIdle idle (  callable $callback  [,  mixed $data  = NULL  [,  int $priority  = 0  ]] )
代码语言:javascript
复制
public void invokePending ( void )
代码语言:javascript
复制
final public EvIo io (  mixed $fd  ,  int $events  ,  callable $callback  [,  mixed $data  = NULL  [,  int $priority  = 0  ]] )
代码语言:javascript
复制
public void loopFork ( void )
代码语言:javascript
复制
public double now ( void )
代码语言:javascript
复制
public void nowUpdate ( void )
代码语言:javascript
复制
final public EvPeriodic periodic (  double $offset  ,  double $interval  ,  callable $callback  [,  mixed $data  = NULL  [,  int $priority  = 0  ]] )
代码语言:javascript
复制
final public EvPrepare prepare (  callable $callback  [,  mixed $data  = NULL  [,  int $priority  = 0  ]] )
代码语言:javascript
复制
public void resume ( void )
代码语言:javascript
复制
public void run ([  int $flags  = 0  ] )
代码语言:javascript
复制
final public EvSignal signal (  int $signum  ,  callable $callback  [,  mixed $data  = NULL  [,  int $priority  = 0  ]] )
代码语言:javascript
复制
final public EvStat stat (  string $path  ,  double $interval  ,  callable $callback  [,  mixed $data  = NULL  [,  int $priority  = 0  ]] )
代码语言:javascript
复制
public void stop ([  int $how  ] )
代码语言:javascript
复制
public void suspend ( void )
代码语言:javascript
复制
final public EvTimer timer (  double $after  ,  double $repeat  ,  callable $callback  [,  mixed $data  = NULL  [,  int $priority  = 0  ]] )
代码语言:javascript
复制
public void verify ( void )

}

Properties

data

Custom data attached to loop

backend

Readonly . The backend flags indicating the event backend in use.

is_default_loop

Readonly . TRUE if it is the default event loop.

iteration

The current iteration count of the loop. See Ev::iteration()

pending

The number of pending watchers. 0 indicates that there are no watchers pending.

io_interval

Higher io_interval allows libev to spend more time collecting EvIo events, so more events can be handled per iteration, at the cost of increasing latency. Timeouts (both EvPeriodic and EvTimer ) will not be affected. Setting this to a non-zero value will introduce an additional sleep() call into most loop iterations. The sleep time ensures that libev will not poll for EvIo events more often than once per this interval, on average. Many programs can usually benefit by setting the io_interval to a value near 0.1 , which is often enough for interactive servers(not for games). It usually doesn't make much sense to set it to a lower value than 0.01 , as this approaches the timing granularity of most systems.

timeout_interval

Higher timeout_interval allows libev to spend more time collecting timeouts, at the expense of increased latency/jitter/inexactness(the watcher callback will be called later). EvIo watchers will not be affected. Setting this to a non-null value will not introduce any overhead in libev . See also ? FUNCTIONS CONTROLLING EVENT LOOPS .

depth

The recursion depth. See Ev::depth() .

Table of Contents

  • EvLoop::backend — Returns an integer describing the backend used by libev.
  • EvLoop::check — Creates EvCheck object associated with the current event loop instance
  • EvLoop::child — Creates EvChild object associated with the current event loop
  • EvLoop::__construct — Constructs the event loop object
  • EvLoop::defaultLoop — Returns or creates the default event loop.
  • EvLoop::embed — Creates an instance of EvEmbed watcher associated with the current EvLoop object.
  • EvLoop::fork — Creates EvFork watcher object associated with the current event loop instance
  • EvLoop::idle — Creates EvIdle watcher object associated with the current event loop instance
  • EvLoop::invokePending — Invoke all pending watchers while resetting their pending state
  • EvLoop::io — Create EvIo watcher object associated with the current event loop instance
  • EvLoop::loopFork — Must be called after a fork
  • EvLoop::nowUpdate — Establishes the current time by querying the kernel, updating the time returned by EvLoop::now in the progress.
  • EvLoop::periodic — Creates EvPeriodic watcher object associated with the current event loop instance
  • EvLoop::prepare — Creates EvPrepare watcher object associated with the current event loop instance
  • EvLoop::resume — Resume previously suspended default event loop
  • EvLoop::run — Begin checking for events and calling callbacks for the loop
  • EvLoop::signal — Creates EvSignal watcher object associated with the current event loop instance
  • EvLoop::stat — Creates EvStat watcher object associated with the current event loop instance
  • EvLoop::stop — Stops the event loop
  • EvLoop::suspend — Suspend the loop
  • EvLoop::timer — Creates EvTimer watcher object associated with the current event loop instance
  • EvLoop::verify — Performs internal consistency checks(for debugging)

← EvIo::set

EvLoop::backend →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com