PHP Interface Kraken\Loop\LoopModelInterface

Show file 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.
erase ( boolean $all = false ) : Kraken\Loop\LoopModelInterface Flush loop.
export ( Kraken\Loop\LoopModelInterface $loop, boolean $all = false ) : Kraken\Loop\LoopModelInterface Export loop not fired handlers and/or streams to another loop model.
getFlowController ( ) : FlowController Return FlowController used by model.
import ( Kraken\Loop\LoopModelInterface $loop, boolean $all = false ) : Kraken\Loop\LoopModelInterface Import handlers and/or streams from another loop model.
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.
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.
setFlowController ( mixed $flowController ) Set FlowController used by model.
start ( ) Run the event loop until there are no more tasks to perform.
stop ( ) Instruct a running event loop to stop.
swap ( Kraken\Loop\LoopModelInterface $loop, boolean $all = false ) : Kraken\Loop\LoopModelInterface Swap handlers and/or stream between loop models.
tick ( ) Perform a single iteration of the event loop.

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

erase() public method

Flush loop.
public erase ( boolean $all = false ) : Kraken\Loop\LoopModelInterface
$all boolean
return Kraken\Loop\LoopModelInterface

export() public method

Export loop not fired handlers and/or streams to another loop model.
public export ( Kraken\Loop\LoopModelInterface $loop, boolean $all = false ) : Kraken\Loop\LoopModelInterface
$loop Kraken\Loop\LoopModelInterface
$all boolean
return Kraken\Loop\LoopModelInterface

getFlowController() public method

Return FlowController used by model.
public getFlowController ( ) : FlowController
return Kraken\Loop\Flow\FlowController

import() public method

Import handlers and/or streams from another loop model.
public import ( Kraken\Loop\LoopModelInterface $loop, boolean $all = false ) : Kraken\Loop\LoopModelInterface
$loop Kraken\Loop\LoopModelInterface
$all boolean
return Kraken\Loop\LoopModelInterface

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

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

setFlowController() public method

Set FlowController used by model.
public setFlowController ( mixed $flowController )
$flowController mixed

start() public method

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

stop() public method

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

swap() public method

Swap handlers and/or stream between loop models.
public swap ( Kraken\Loop\LoopModelInterface $loop, boolean $all = false ) : Kraken\Loop\LoopModelInterface
$loop Kraken\Loop\LoopModelInterface
$all boolean
return Kraken\Loop\LoopModelInterface

tick() public method

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