PHP Class Workerman\Events\React

Inheritance: implements React\EventLoop\LoopInterface
Show file Open project: walkor/workerman

Protected Properties

Property Type Description
$_loop React\EventLoop\LoopInterface

Public Methods

Method Description
__construct ( ) React constructor.
add ( $fd, $flag, $func, array $args = [] ) : boolean Add event listener to event loop.
addPeriodicTimer ( integer | float $interval, callable $callback ) : React\EventLoop\Timer\TimerInterface Enqueue a callback to be invoked repeatedly after the given interval.
addReadStream ( resource $stream, callable $listener ) Register a listener to be notified when a stream is ready to read.
addTimer ( integer | float $interval, callable $callback ) : React\EventLoop\Timer\TimerInterface Enqueue a callback to be invoked once after the given interval.
addWriteStream ( resource $stream, callable $listener ) Register a listener to be notified when a stream is ready to write.
cancelTimer ( React\EventLoop\Timer\TimerInterface $timer ) Cancel a pending timer.
del ( mixed $fd, integer $flag ) : boolean Remove event listener from event loop.
futureTick ( callable $listener ) Schedule a callback to be invoked on a future tick of the event loop.
isTimerActive ( React\EventLoop\Timer\TimerInterface $timer ) : boolean Check if a given timer is active.
loop ( ) : void Main loop.
nextTick ( callable $listener ) Schedule a callback to be invoked on the next tick of the event loop.
removeReadStream ( resource $stream ) Remove the read event listener for the given stream.
removeStream ( resource $stream ) Remove all listeners for the given stream.
removeWriteStream ( resource $stream ) Remove the write event listener for the given stream.
run ( ) Run the event loop until there are no more tasks to perform.
stop ( ) Instruct a running event loop to stop.
tick ( ) Perform a single iteration of the event loop.

Method Details

__construct() public method

React constructor.
public __construct ( )

add() public method

Add event listener to event loop.
public add ( $fd, $flag, $func, array $args = [] ) : boolean
$fd
$flag
$func
$args array
return boolean

addPeriodicTimer() public method

The execution order of timers scheduled to execute at the same time is not guaranteed.
public addPeriodicTimer ( integer | float $interval, callable $callback ) : React\EventLoop\Timer\TimerInterface
$interval integer | float The number of seconds to wait before execution.
$callback callable The callback to invoke.
return React\EventLoop\Timer\TimerInterface

addReadStream() public method

Register a listener to be notified when a stream is ready to read.
public addReadStream ( resource $stream, callable $listener )
$stream resource The PHP stream resource to check.
$listener callable Invoked when the stream is ready.

addTimer() public method

The execution order of timers scheduled to execute at the same time is not guaranteed.
public addTimer ( integer | float $interval, callable $callback ) : React\EventLoop\Timer\TimerInterface
$interval integer | float The number of seconds to wait before execution.
$callback callable The callback to invoke.
return React\EventLoop\Timer\TimerInterface

addWriteStream() public method

Register a listener to be notified when a stream is ready to write.
public addWriteStream ( resource $stream, callable $listener )
$stream resource The PHP stream resource to check.
$listener callable Invoked when the stream is ready.

cancelTimer() public method

Cancel a pending timer.
public cancelTimer ( React\EventLoop\Timer\TimerInterface $timer )
$timer React\EventLoop\Timer\TimerInterface The timer to cancel.

del() public method

Remove event listener from event loop.
public del ( mixed $fd, integer $flag ) : boolean
$fd mixed
$flag integer
return boolean

futureTick() public method

Callbacks are guaranteed to be executed in the order they are enqueued.
public futureTick ( callable $listener )
$listener callable The callback to invoke.

isTimerActive() public method

Check if a given timer is active.
public isTimerActive ( React\EventLoop\Timer\TimerInterface $timer ) : boolean
$timer React\EventLoop\Timer\TimerInterface The timer to check.
return boolean True if the timer is still enqueued for execution.

loop() public method

Main loop.
public loop ( ) : void
return void

nextTick() public method

Callbacks are guaranteed to be executed in the order they are enqueued, before any timer or stream events.
public nextTick ( callable $listener )
$listener callable The callback to invoke.

removeReadStream() public method

Remove the read event listener for the given stream.
public removeReadStream ( resource $stream )
$stream resource The PHP stream resource.

removeStream() public method

Remove all listeners for the given stream.
public removeStream ( resource $stream )
$stream resource The PHP stream resource.

removeWriteStream() public method

Remove the write event listener for the given stream.
public removeWriteStream ( resource $stream )
$stream resource The PHP stream resource.

run() public method

Run the event loop until there are no more tasks to perform.
public run ( )

stop() public method

Instruct a running event loop to stop.
public stop ( )

tick() public method

Perform a single iteration of the event loop.
public tick ( )

Property Details

$_loop protected property

protected LoopInterface,React\EventLoop $_loop
return React\EventLoop\LoopInterface