Constants

MICROSECONDS_PER_SECOND

MICROSECONDS_PER_SECOND

Properties

$eventBase

$eventBase

$nextTickQueue

$nextTickQueue

$futureTickQueue

$futureTickQueue

$timerCallback

$timerCallback

$timerEvents

$timerEvents

$streamCallback

$streamCallback

$streamEvents

$streamEvents

$streamFlags

$streamFlags

$readListeners

$readListeners

$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.

subscribeStreamEvent()

subscribeStreamEvent(\React\EventLoop\stream $stream, integer $flag)

Create a new ext-libevent event resource, or update the existing one.

Parameters

\React\EventLoop\stream $stream
integer $flag

EV_READ or EV_WRITE

unsubscribeStreamEvent()

unsubscribeStreamEvent(\React\EventLoop\stream $stream, integer $flag)

Update the ext-libevent event resource for this stream to stop listening to the given event type, or remove it entirely if it's no longer needed.

Parameters

\React\EventLoop\stream $stream
integer $flag

EV_READ or EV_WRITE

createTimerCallback()

createTimerCallback()

Create a callback used as the target of timer events.

A reference is kept to the callback for the lifetime of the loop to prevent "Cannot destroy active lambda function" fatal error from the event extension.

createStreamCallback()

createStreamCallback()

Create a callback used as the target of stream events.

A reference is kept to the callback for the lifetime of the loop to prevent "Cannot destroy active lambda function" fatal error from the event extension.