Constants

MICROSECONDS_PER_SECOND

MICROSECONDS_PER_SECOND

Properties

$nextTickQueue

$nextTickQueue

$futureTickQueue

$futureTickQueue

$timers

$timers

$readStreams

$readStreams

$readListeners

$readListeners

$writeStreams

$writeStreams

$writeListeners

$writeListeners

$running

$running

Methods

__construct()

__construct()

addReadStream()

addReadStream( $stream, callable $listener)

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

Parameters

$stream
callable $listener

addWriteStream()

addWriteStream( $stream, callable $listener)

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

Parameters

$stream
callable $listener

removeReadStream()

removeReadStream( $stream)

Remove the read event listener for the given stream.

Parameters

$stream

removeWriteStream()

removeWriteStream( $stream)

Remove the write event listener for the given stream.

Parameters

$stream

removeStream()

removeStream( $stream)

Remove all listeners for the given stream.

Parameters

$stream

addTimer()

addTimer( $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

$interval
callable $callback

Returns

\React\EventLoop\Timer\TimerInterface

addPeriodicTimer()

addPeriodicTimer( $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

$interval
callable $callback

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

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

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

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.

streamSelect()

streamSelect(array $read, array $write, integer|null $timeout) : integer

Emulate a stream_select() implementation that does not break when passed empty stream arrays.

Parameters

array $read
array $write
integer|null $timeout

Activity timeout in microseconds, or null to wait forever.

Returns

integer —

The total number of streams that are ready for read/write.

waitForStreamActivity()

waitForStreamActivity( $timeout)

Wait/check for stream activity, or until the next timer is due.

Parameters

$timeout