PHP Interface Kraken\Loop\LoopInterface

ファイルを表示 Open project: kraken-php/framework Interface Usage Examples

Public Methods

Method Description
addPeriodicTimer ( float $interval, callable $callback ) : Kraken\Loop\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 ( float $interval, callable $callback ) : Kraken\Loop\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 ( Kraken\Loop\Timer\TimerInterface $timer ) Cancel a pending timer.
isRunning ( ) : boolean Check if loop is currently running.
isTimerActive ( Kraken\Loop\Timer\TimerInterface $timer ) : boolean Check if a given timer is active.
onAfterTick ( callable $listener ) Schedule a callback to be invoked on a future tick of the event loop.
onBeforeTick ( callable $listener ) Schedule a callback to be invoked on the next tick of the event loop.
onStart ( callable $listener ) Schedule a callback to be invoked on the start tick of event loop.
onStop ( callable $listener ) Schedule a callback to be invoked on the stop tick of event loop.
onTick ( callable $listener ) Schedule a callback to be invoked on a future 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.

Method Details

addPeriodicTimer() public method

The execution order of timers scheduled to execute at the same time is not guaranteed.
public addPeriodicTimer ( float $interval, callable $callback ) : Kraken\Loop\Timer\TimerInterface
$interval float
$callback callable
return Kraken\Loop\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
$listener callable

addTimer() public method

The execution order of timers scheduled to execute at the same time is not guaranteed.
public addTimer ( float $interval, callable $callback ) : Kraken\Loop\Timer\TimerInterface
$interval float
$callback callable
return Kraken\Loop\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
$listener callable

cancelTimer() public method

Cancel a pending timer.
public cancelTimer ( Kraken\Loop\Timer\TimerInterface $timer )
$timer Kraken\Loop\Timer\TimerInterface

isRunning() public method

Check if loop is currently running.
public isRunning ( ) : boolean
return boolean

isTimerActive() public method

Check if a given timer is active.
public isTimerActive ( Kraken\Loop\Timer\TimerInterface $timer ) : boolean
$timer Kraken\Loop\Timer\TimerInterface
return boolean

onAfterTick() public method

Callbacks are guaranteed to be executed in the order they are enqueued.
public onAfterTick ( callable $listener )
$listener callable

onBeforeTick() public method

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

onStart() public method

Callbacks are guarenteed to be executed in the order they are enqueued, before anything else.
public onStart ( callable $listener )
$listener callable

onStop() public method

Callbacks are guarenteed to be executed in the order they are enqueued.
public onStop ( callable $listener )
$listener callable

onTick() public method

Callbacks are guaranteed to be executed in the order they are enqueued. This method is an alias for onAfterTick() method.
public onTick ( callable $listener )
$listener callable

removeReadStream() public method

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

removeStream() public method

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

removeWriteStream() public method

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