Methods

addReadStream()

addReadStream(\React\EventLoop\stream $stream, callable $listener)

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

Parameters

\React\EventLoop\stream $stream

The PHP stream resource to check.

callable $listener

Invoked when the stream is ready.

addWriteStream()

addWriteStream(\React\EventLoop\stream $stream, callable $listener)

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

Parameters

\React\EventLoop\stream $stream

The PHP stream resource to check.

callable $listener

Invoked when the stream is ready.

removeReadStream()

removeReadStream(\React\EventLoop\stream $stream)

Remove the read event listener for the given stream.

Parameters

\React\EventLoop\stream $stream

The PHP stream resource.

removeWriteStream()

removeWriteStream(\React\EventLoop\stream $stream)

Remove the write event listener for the given stream.

Parameters

\React\EventLoop\stream $stream

The PHP stream resource.

removeStream()

removeStream(\React\EventLoop\stream $stream)

Remove all listeners for the given stream.

Parameters

\React\EventLoop\stream $stream

The PHP stream resource.

addTimer()

addTimer(\React\EventLoop\numeric $interval, callable $callback) : \React\EventLoop\Timer\TimerInterface

Enqueue a callback to be invoked once after the given interval.

The execution order of timers scheduled to execute at the same time is not guaranteed.

Parameters

\React\EventLoop\numeric $interval

The number of seconds to wait before execution.

callable $callback

The callback to invoke.

Returns

\React\EventLoop\Timer\TimerInterface

addPeriodicTimer()

addPeriodicTimer(\React\EventLoop\numeric $interval, callable $callback) : \React\EventLoop\Timer\TimerInterface

Enqueue a callback to be invoked repeatedly after the given interval.

The execution order of timers scheduled to execute at the same time is not guaranteed.

Parameters

\React\EventLoop\numeric $interval

The number of seconds to wait before execution.

callable $callback

The callback to invoke.

Returns

\React\EventLoop\Timer\TimerInterface

isTimerActive()

isTimerActive(\React\EventLoop\Timer\TimerInterface $timer) : boolean

Check if a given timer is active.

Parameters

\React\EventLoop\Timer\TimerInterface $timer

The timer to check.

Returns

boolean —

True if the timer is still enqueued for execution.

nextTick()

nextTick(callable $listener)

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

Callbacks are guaranteed to be executed in the order they are enqueued, before any timer or stream events.

Parameters

callable $listener

The callback to invoke.

futureTick()

futureTick(callable $listener)

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

Callbacks are guaranteed to be executed in the order they are enqueued.

Parameters

callable $listener

The callback to invoke.

tick()

tick()

Perform a single iteration of the event loop.

run()

run()

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

stop()

stop()

Instruct a running event loop to stop.