Documentation

Loop
in package

FinalYes

The `Loop` class exists as a convenient way to get the currently relevant loop

Table of Contents

Properties

$instance  : LoopInterface|null
$stopped  : bool

Methods

addPeriodicTimer()  : TimerInterface
Enqueue a callback to be invoked repeatedly after the given interval.
addReadStream()  : void
[Advanced] Register a listener to be notified when a stream is ready to read.
addSignal()  : void
Register a listener to be notified when a signal has been caught by this process.
addTimer()  : TimerInterface
Enqueue a callback to be invoked once after the given interval.
addWriteStream()  : void
[Advanced] Register a listener to be notified when a stream is ready to write.
cancelTimer()  : void
Cancel a pending timer.
futureTick()  : void
Schedule a callback to be invoked on a future tick of the event loop.
get()  : LoopInterface
Returns the event loop.
removeReadStream()  : void
Remove the read event listener for the given stream.
removeSignal()  : void
Removes a previously added signal listener.
removeWriteStream()  : void
Remove the write event listener for the given stream.
run()  : void
Run the event loop until there are no more tasks to perform.
stop()  : void
Instruct a running event loop to stop.

Properties

$stopped

private static bool $stopped = false

Methods

addReadStream()

[Advanced] Register a listener to be notified when a stream is ready to read.

public static addReadStream(resource $stream, callable $listener) : void
Parameters
$stream : resource
$listener : callable
Tags
throws
Exception
see
LoopInterface::addReadStream()

addSignal()

Register a listener to be notified when a signal has been caught by this process.

public static addSignal(int $signal, callable $listener) : void
Parameters
$signal : int
$listener : callable
Tags
see
LoopInterface::addSignal()

addWriteStream()

[Advanced] Register a listener to be notified when a stream is ready to write.

public static addWriteStream(resource $stream, callable $listener) : void
Parameters
$stream : resource
$listener : callable
Tags
throws
Exception
see
LoopInterface::addWriteStream()

futureTick()

Schedule a callback to be invoked on a future tick of the event loop.

public static futureTick(callable $listener) : void
Parameters
$listener : callable
Tags
see
LoopInterface::futureTick()

get()

Returns the event loop.

public static get() : LoopInterface

When no loop is set, it will call the factory to create one.

This method always returns an instance implementing LoopInterface, the actual event loop implementation is an implementation detail.

This method is the preferred way to get the event loop and using Factory::create has been deprecated.

Return values
LoopInterface

removeReadStream()

Remove the read event listener for the given stream.

public static removeReadStream(resource $stream) : void
Parameters
$stream : resource
Tags
see
LoopInterface::removeReadStream()

removeSignal()

Removes a previously added signal listener.

public static removeSignal(int $signal, callable $listener) : void
Parameters
$signal : int
$listener : callable
Tags
see
LoopInterface::removeSignal()

removeWriteStream()

Remove the write event listener for the given stream.

public static removeWriteStream(resource $stream) : void
Parameters
$stream : resource
Tags
see
LoopInterface::removeWriteStream()

run()

Run the event loop until there are no more tasks to perform.

public static run() : void
Tags
see
LoopInterface::run()

        
On this page

Search results