PHPのお勉強!

PHP TOP

The EvLoop class

(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.

クラス概要

final class EvLoop {
/* プロパティ */
public $data;
public $backend;
public $iteration;
public $pending;
public $io_interval;
public $depth;
/* メソッド */
public __construct(
     int $flags = ?,
     mixed $data = NULL ,
     float $io_interval = 0.0 ,
     float $timeout_interval = 0.0
)
public backend(): int
final public check( string $callback , string $data = ?, string $priority = ?): EvCheck
final public child(
     string $pid ,
     string $trace ,
     string $callback ,
     string $data = ?,
     string $priority = ?
): EvChild
public static defaultLoop(
     int $flags = Ev::FLAG_AUTO ,
     mixed $data = NULL ,
     float $io_interval = 0. ,
     float $timeout_interval = 0.
): EvLoop
final public embed(
     string $other ,
     string $callback = ?,
     string $data = ?,
     string $priority = ?
): EvEmbed
final public fork( callable $callback , mixed $data = null , int $priority = 0 ): EvFork
final public idle( callable $callback , mixed $data = null , int $priority = 0 ): EvIdle
final public io(
     mixed $fd ,
     int $events ,
     callable $callback ,
     mixed $data = null ,
     int $priority = 0
): EvIo
public loopFork(): void
public now(): float
public nowUpdate(): void
final public periodic(
     float $offset ,
     float $interval ,
     callable $callback ,
     mixed $data = null ,
     int $priority = 0
): EvPeriodic
final public prepare( callable $callback , mixed $data = null , int $priority = 0 ): EvPrepare
public resume(): void
public run( int $flags = 0 ): void
final public signal(
     int $signum ,
     callable $callback ,
     mixed $data = null ,
     int $priority = 0
): EvSignal
final public stat(
     string $path ,
     float $interval ,
     callable $callback ,
     mixed $data = null ,
     int $priority = 0
): EvStat
public stop( int $how = ?): void
public suspend(): void
final public timer(
     float $after ,
     float $repeat ,
     callable $callback ,
     mixed $data = null ,
     int $priority = 0
): EvTimer
public verify(): void
}

プロパティ

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.

See also » FUNCTIONS CONTROLLING EVENT LOOPS .

timeout_interval

Higher