ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
|
A simple eventloop implementation. More...
Public Member Functions | |
setTimeout (callable $cb, $timeout) | |
Executes a function after x seconds. More... | |
setInterval (callable $cb, $timeout) | |
Executes a function every x seconds. More... | |
clearInterval ($intervalId) | |
Stops a running internval. More... | |
nextTick (callable $cb) | |
Runs a function immediately at the next iteration of the loop. More... | |
addReadStream ($stream, callable $cb) | |
Adds a read stream. More... | |
addWriteStream ($stream, callable $cb) | |
Adds a write stream. More... | |
removeReadStream ($stream) | |
Stop watching a stream for reads. More... | |
removeWriteStream ($stream) | |
Stop watching a stream for writes. More... | |
run () | |
Runs the loop. More... | |
tick ($block=false) | |
Executes all pending events. More... | |
stop () | |
Stops a running eventloop. More... | |
Protected Member Functions | |
runNextTicks () | |
Executes all 'nextTick' callbacks. More... | |
runTimers () | |
Runs all pending timers. More... | |
runStreams ($timeout) | |
Runs all pending stream events. More... | |
Protected Attributes | |
$running = false | |
$timers = [] | |
$nextTick = [] | |
$readStreams = [] | |
$writeStreams = [] | |
$readCallbacks = [] | |
$writeCallbacks = [] | |
A simple eventloop implementation.
This eventloop supports:
Sabre\Event\Loop\Loop::addReadStream | ( | $stream, | |
callable | $cb | ||
) |
Adds a read stream.
The callback will be called as soon as there is something to read from the stream.
You MUST call removeReadStream after you are done with the stream, to prevent the eventloop from never stopping.
resource | $stream | |
callable | $cb |
Definition at line 132 of file Loop.php.
References GuzzleHttp\Psr7\$stream.
Sabre\Event\Loop\Loop::addWriteStream | ( | $stream, | |
callable | $cb | ||
) |
Adds a write stream.
The callback will be called as soon as the system reports it's ready to receive writes on the stream.
You MUST call removeWriteStream after you are done with the stream, to prevent the eventloop from never stopping.
resource | $stream | |
callable | $cb |
Definition at line 152 of file Loop.php.
References GuzzleHttp\Psr7\$stream.
Sabre\Event\Loop\Loop::clearInterval | ( | $intervalId | ) |
Sabre\Event\Loop\Loop::nextTick | ( | callable | $cb | ) |
Runs a function immediately at the next iteration of the loop.
callable | $cb |
Definition at line 112 of file Loop.php.
Referenced by Sabre\Event\Loop\Loop\runNextTicks(), Sabre\Event\Loop\Loop\runStreams(), and Sabre\Event\Loop\Loop\tick().
Sabre\Event\Loop\Loop::removeReadStream | ( | $stream | ) |
Stop watching a stream for reads.
resource | $stream |
Definition at line 165 of file Loop.php.
References GuzzleHttp\Psr7\$stream.
Sabre\Event\Loop\Loop::removeWriteStream | ( | $stream | ) |
Stop watching a stream for writes.
resource | $stream |
Definition at line 180 of file Loop.php.
References GuzzleHttp\Psr7\$stream.
Sabre\Event\Loop\Loop::run | ( | ) |
Runs the loop.
This function will run continiously, until there's no more events to handle.
Definition at line 198 of file Loop.php.
References Sabre\Event\Loop\Loop\tick().
|
protected |
Executes all 'nextTick' callbacks.
return void
Definition at line 268 of file Loop.php.
References Sabre\Event\Loop\Loop\$nextTick, and Sabre\Event\Loop\Loop\nextTick().
Referenced by Sabre\Event\Loop\Loop\tick().
|
protected |
Runs all pending stream events.
float | $timeout |
Definition at line 308 of file Loop.php.
References Sabre\Event\Loop\Loop\$readStreams, Sabre\Event\Loop\Loop\$writeStreams, and Sabre\Event\Loop\Loop\nextTick().
Referenced by Sabre\Event\Loop\Loop\tick().
|
protected |
Runs all pending timers.
After running the timer callbacks, this function returns the number of seconds until the next timer should be executed.
If there's no more pending timers, this function returns null.
Definition at line 289 of file Loop.php.
Referenced by Sabre\Event\Loop\Loop\tick().
Sabre\Event\Loop\Loop::setInterval | ( | callable | $cb, |
$timeout | |||
) |
Executes a function every x seconds.
The value this function returns can be used to stop the interval with clearInterval.
callable | $cb | |
float | $timeout |
Definition at line 71 of file Loop.php.
References $f, and Sabre\Event\Loop\Loop\setTimeout().
Sabre\Event\Loop\Loop::setTimeout | ( | callable | $cb, |
$timeout | |||
) |
Executes a function after x seconds.
callable | $cb | |
float | $timeout | timeout in seconds |
Definition at line 27 of file Loop.php.
References $index.
Referenced by Sabre\Event\Loop\Loop\setInterval().
Sabre\Event\Loop\Loop::stop | ( | ) |
Sabre\Event\Loop\Loop::tick | ( | $block = false | ) |
Executes all pending events.
If $block is turned true, this function will block until any event is triggered.
If there are now timeouts, nextTick callbacks or events in the loop at all, this function will exit immediately.
This function will return true if there are any events left in the loop after the tick.
bool | $block |
Definition at line 226 of file Loop.php.
References Sabre\Event\Loop\Loop\nextTick(), Sabre\Event\Loop\Loop\runNextTicks(), Sabre\Event\Loop\Loop\runStreams(), and Sabre\Event\Loop\Loop\runTimers().
Referenced by Sabre\Event\Loop\Loop\run().
|
protected |
Definition at line 355 of file Loop.php.
Referenced by Sabre\Event\Loop\Loop\runNextTicks().
|
protected |
Definition at line 362 of file Loop.php.
Referenced by Sabre\Event\Loop\Loop\runStreams().
|
protected |
Definition at line 369 of file Loop.php.
Referenced by Sabre\Event\Loop\Loop\runStreams().