EvLoop
final class EvLoop (View source)
Class EvLoop
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 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.
Properties
int | $backend | ||
bool | $is_default_loop | ||
mixed | $data | ||
int | $iteration | ||
int | $pending | ||
float | $io_interval | ||
float | $timeout_interval | ||
int | $depth |
Methods
No description
Returns an integer describing the backend used by libev.
Creates EvCheck object associated with the current event loop instance.
Creates EvChild object associated with the current event loop instance;
Creates EvFork object associated with the current event loop instance.
Creates EvIdle object associated with the current event loop instance.
Invoke all pending watchers while resetting their pending state.
Creates EvIo object associated with the current event loop instance.
Must be called after a fork.
Returns the current "event loop time".
Establishes the current time by querying the kernel, updating the time returned by Ev::now in the progress.
Creates EvPeriodic object associated with the current event loop instance.
Creates EvPrepare object associated with the current event loop instance.
Resume previously suspended default event loop.
Begin checking for events and calling callbacks for the loop.
Creates EvSignal object associated with the current event loop instance.
Creates EvStats object associated with the current event loop instance.
Stops the event loop.
Suspend the loop.
Creates EvTimer object associated with the current event loop instance.
Performs internal consistency checks (for debugging).
Returns or creates the default event loop.
Details
__construct(int $flags = Ev::FLAG_AUTO, mixed $data = null, float $io_interval = 0.0, float $timeout_interval = 0.0)
No description
int
backend()
Returns an integer describing the backend used by libev.
final EvCheck
check(callable $callback, mixed $data = null, int $priority = 0)
Creates EvCheck object associated with the current event loop instance.
final EvChild
child(int $pid, bool $trace, mixed $callback, mixed $data = null, int $priority = 0)
Creates EvChild object associated with the current event loop instance;
final EvEmbed
embed(EvLoop $other, callable $callback, mixed $data = null, int $priority = 0)
Creates EvEmbed object associated with the current event loop instance.
final EvFork
fork(callable $callback, mixed $data = null, int $priority = 0)
Creates EvFork object associated with the current event loop instance.
final EvIdle
idle(mixed $callback, mixed $data = null, int $priority = 0)
Creates EvIdle object associated with the current event loop instance.
invokePending()
Invoke all pending watchers while resetting their pending state.
final EvIo
io(mixed $fd, int $events, mixed $callback, mixed $data = null, int $priority = 0)
Creates EvIo object associated with the current event loop instance.
loopFork()
Must be called after a fork.
Must be called after a fork in the child, before entering or continuing the event loop. An alternative is to use Ev::FLAG_FORKCHECK which calls this function automatically, at some performance loss (refer to the libev documentation).
float
now()
Returns the current "event loop time".
Returns the current "event loop time", which is the time the event loop received events and started processing them. This timestamp does not change as long as callbacks are being processed, and this is also the base time used for relative timers. You can treat it as the timestamp of the event occurring (or more correctly, libev finding out about it).
nowUpdate()
Establishes the current time by querying the kernel, updating the time returned by Ev::now in the progress.
Establishes the current time by querying the kernel, updating the time returned by Ev::now() in the progress. This is a costly operation and is usually done automatically within Ev::run().
This method is rarely useful, but when some event callback runs for a very long time without entering the event loop, updating libev's consideration of the current time is a good idea.
final
periodic(float $offset, float $interval, mixed $reschedule_cb, mixed $callback, mixed $data = null, int $priority = 0)
Creates EvPeriodic object associated with the current event loop instance.
final
prepare(callable $callback, mixed $data = null, int $priority = 0)
Creates EvPrepare object associated with the current event loop instance.
resume()
Resume previously suspended default event loop.
EvLoop::suspend() and EvLoop::resume() methods suspend and resume a loop correspondingly.
run(int $flags = Ev::FLAG_AUTO)
Begin checking for events and calling callbacks for the loop.
Begin checking for events and calling callbacks for the current event loop. Returns when a callback calls Ev::stop() method, or the flags are nonzero (in which case the return value is true) or when there are no active watchers which reference the loop (EvWatcher::keepalive() is TRUE), in which case the return value will be FALSE. The return value can generally be interpreted as if TRUE, there is more work left to do.
final EvSignal
signal(int $signum, mixed $callback, mixed $data = null, int $priority = 0)
Creates EvSignal object associated with the current event loop instance.
final EvStat
stat(string $path, float $interval, mixed $callback, mixed $data = null, int $priority = 0)
Creates EvStats object associated with the current event loop instance.
stop(int $how = Ev::BREAK_ALL)
Stops the event loop.
suspend()
Suspend the loop.
EvLoop::suspend() and EvLoop::resume() methods suspend and resume a loop correspondingly.
final EvTimer
timer(float $after, float $repeat, mixed $callback, mixed $data = null, int $priority = 0)
Creates EvTimer object associated with the current event loop instance.
verify()
Performs internal consistency checks (for debugging).
Performs internal consistency checks (for debugging libev) and abort the program if any data structures were found to be corrupted.
static EvLoop
defaultLoop(int $flags = Ev::FLAG_AUTO, mixed $data = null, float $io_interval = 0.0, float $timeout_interval = 0.0)
Returns or creates the default event loop.
If the default event loop is not created, EvLoop::defaultLoop() creates it with the specified parameters. Otherwise, it just returns the object representing previously created instance ignoring all the parameters.