A classe EvLoop

(PECL ev >= 0.2.0)

Introdução

Representa um loop de eventos que é sempre distinto do loop padrão. Ao contrário do loop padrão, ele não pode lidar com observadores EvChild.

Tendo threads, temos que criar um loop por thread e usar o loop padrão no thread pai.

O loop de eventos padrão é inicializado automaticamente por Ev. É acessível através de métodos da classe Ev, ou através do método EvLoop::defaultLoop().

Resumo da classe

final class EvLoop {
/* Propriedades */
public $data;
public $backend;
public $iteration;
public $pending;
public $io_interval;
public $depth;
/* Métodos */
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
}

Propriedades

data

Dados personalizados anexados ao loop

backend

Somente Leitura. As opções de backend indicando o backend do evento em uso.

is_default_loop

Somente Leitura. true se for o loop de eventos padrão.

iteration

A contagem de iterações atuais do loop. Veja Ev::iteration()

pending

O número de observadores pendentes. 0 indica que não há observadores pendentes.

io_interval

Um io_interval mais alto permite que libev gaste mais tempo coletando eventos EvIo, para que mais eventos possam ser tratados por iteração, ao custo de aumentar a latência. Os tempos limite (EvPeriodic e EvTimer ) não serão afetados. Definir isso com um valor diferente de zero introduzirá uma chamada sleep() adicional na maioria das iterações de loop. O tempo de suspensão garante que libev não pesquisará eventos EvIo mais de uma vez por esse intervalo, em média. Muitos programas geralmente podem se beneficiar configurando o io_interval para um valor próximo de 0.1, o que geralmente é suficiente para servidores interativos (não para jogos). Geralmente não faz muito sentido defini-lo com um valor inferior a 0.01, pois isso se aproxima da granularidade de tempo da maioria dos sistemas.

Veja também » FUNÇÕES DE CONTROLE DE LOOPS DE EVENTOS .

timeout_interval

Um timeout_interval maior permite que libev gaste mais tempo coletando tempos limite, às custas de maior latência/jitter/inexatidão (o retorno de chamada do inspetor será chamado mais tarde). Os observadores de EvIo não serão afetados. Definir isso como um valor não nulo não introduzirá nenhuma sobrecarga no libev . Veja também » FUNÇÕES DE CONTROLE DE LOOPS DE EVENTOS .

depth

A profundidade da recursão. Veja Ev::depth() .

Índice

  • 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::now — Returns the current "event loop time"
  • 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)
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top