ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\Event\Loop Namespace Reference

Data Structures

class  FunctionsTest
 
class  Loop
 A simple eventloop implementation. More...
 
class  LoopTest
 

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...
 
 instance (Loop $newLoop=null)
 Retrieves or sets the global Loop object. More...
 

Function Documentation

◆ addReadStream()

Sabre\Event\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.

Parameters
resource$stream
callable$cb
Returns
void

Definition at line 72 of file functions.php.

References GuzzleHttp\Psr7\$stream, and Sabre\Event\Loop\instance().

Referenced by Sabre\Event\Loop\FunctionsTest\testAddReadStream().

72  {
73 
74  instance()->addReadStream($stream, $cb);
75 
76 }
$stream
PHP stream implementation.
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addWriteStream()

Sabre\Event\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.

Parameters
resource$stream
callable$cb
Returns
void

Definition at line 91 of file functions.php.

References GuzzleHttp\Psr7\$stream, and Sabre\Event\Loop\instance().

Referenced by Sabre\Event\Loop\FunctionsTest\testAddWriteStream().

91  {
92 
93  instance()->addWriteStream($stream, $cb);
94 
95 }
$stream
PHP stream implementation.
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearInterval()

Sabre\Event\Loop\clearInterval (   $intervalId)

Stops a running internval.

Parameters
array$intervalId
Returns
void

Definition at line 40 of file functions.php.

References Sabre\Event\Loop\instance().

Referenced by Sabre\Event\Loop\FunctionsTest\testSetInterval().

40  {
41 
42  instance()->clearInterval($intervalId);
43 
44 }
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instance()

Sabre\Event\Loop\instance ( Loop  $newLoop = null)

◆ nextTick()

◆ removeReadStream()

Sabre\Event\Loop\removeReadStream (   $stream)

Stop watching a stream for reads.

Parameters
resource$stream
Returns
void

Definition at line 103 of file functions.php.

References GuzzleHttp\Psr7\$stream, and Sabre\Event\Loop\instance().

Referenced by Sabre\Event\Loop\FunctionsTest\testAddReadStream().

103  {
104 
105  instance()->removeReadStream($stream);
106 
107 }
$stream
PHP stream implementation.
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeWriteStream()

Sabre\Event\Loop\removeWriteStream (   $stream)

Stop watching a stream for writes.

Parameters
resource$stream
Returns
void

Definition at line 115 of file functions.php.

References GuzzleHttp\Psr7\$stream, and Sabre\Event\Loop\instance().

Referenced by Sabre\Event\Loop\FunctionsTest\testAddWriteStream().

115  {
116 
117  instance()->removeWriteStream($stream);
118 
119 }
$stream
PHP stream implementation.
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

Sabre\Event\Loop\run ( )

Runs the loop.

This function will run continiously, until there's no more events to handle.

Returns
void

Definition at line 130 of file functions.php.

References Sabre\Event\Loop\instance().

Referenced by ilLOTestQuestionAdapter\initTestRun(), ilLOTestQuestionAdapter\initUserResult(), ilLOTestQuestionAdapter\isInRun(), printHelp(), Whoops\Handler\Handler\setRun(), ilLOTestQuestionAdapter\storeTestRun(), Sabre\Event\Loop\FunctionsTest\testAddReadStream(), Sabre\Event\Loop\FunctionsTest\testAddWriteStream(), Sabre\Event\Promise\FunctionsTest\testAll(), Sabre\Event\PromiseTest\testAll(), Sabre\Event\Promise\PromiseTest\testAll(), Sabre\Event\Promise\FunctionsTest\testAllReject(), Sabre\Event\PromiseTest\testAllReject(), Sabre\Event\Promise\PromiseTest\testAllReject(), Sabre\Event\Promise\FunctionsTest\testAllRejectThenResolve(), Sabre\Event\PromiseTest\testAllRejectThenResolve(), Sabre\Event\Promise\PromiseTest\testAllRejectThenResolve(), Sabre\Event\PromiseTest\testChain(), Sabre\Event\Promise\PromiseTest\testChain(), Sabre\Event\PromiseTest\testChainPromise(), Sabre\Event\Promise\PromiseTest\testChainPromise(), Sabre\Event\CoroutineTest\testCoroutineException(), Sabre\Event\CoroutineTest\testDeepException(), Sabre\Event\PromiseTest\testExecutorFail(), Sabre\Event\Promise\PromiseTest\testExecutorFail(), Sabre\Event\PromiseTest\testExecutorSuccess(), Sabre\Event\Promise\PromiseTest\testExecutorSuccess(), Sabre\Event\PromiseTest\testFail(), Sabre\Event\Promise\PromiseTest\testFail(), Sabre\Event\PromiseTest\testFromFailureHandler(), Sabre\Event\Promise\PromiseTest\testFromFailureHandler(), Sabre\Event\CoroutineTest\testFulfilledPromise(), Sabre\Event\CoroutineTest\testFulfilledPromiseAsync(), Sabre\Event\Loop\FunctionsTest\testNextTick(), Sabre\Event\PromiseTest\testPendingFail(), Sabre\Event\Promise\PromiseTest\testPendingFail(), Sabre\Event\PromiseTest\testPendingResult(), Sabre\Event\Promise\PromiseTest\testPendingResult(), Sabre\Event\Promise\FunctionsTest\testRace(), Sabre\Event\PromiseTest\testRace(), Sabre\Event\Promise\FunctionsTest\testRaceReject(), Sabre\Event\PromiseTest\testRaceReject(), Sabre\Event\Promise\FunctionsTest\testReject(), Sabre\Event\CoroutineTest\testRejectedPromise(), Sabre\Event\CoroutineTest\testRejectedPromiseAsync(), Sabre\Event\CoroutineTest\testRejectedPromiseException(), Sabre\Event\Promise\FunctionsTest\testResolve(), Sabre\Event\CoroutineTest\testResolveToLastYield(), Sabre\Event\CoroutineTest\testResolveToLastYieldPromise(), Sabre\Event\Loop\FunctionsTest\testSetInterval(), Sabre\Event\Loop\FunctionsTest\testStop(), Sabre\Event\PromiseTest\testSuccess(), Sabre\Event\Promise\PromiseTest\testSuccess(), Sabre\Event\Loop\FunctionsTest\testTimeout(), Sabre\Event\Loop\FunctionsTest\testTimeoutOrder(), ilLOTestQuestionAdapter\updateFixedQuestions(), ilLOTestQuestionAdapter\updateQuestionResult(), ilLOTestQuestionAdapter\updateRandomQuestions(), and ilLOTestQuestionAdapter\updateSeparateTestQuestions().

130  {
131 
132  instance()->run();
133 
134 }
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setInterval()

Sabre\Event\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.

Parameters
callable$cb
float$timeout
Returns
array

Definition at line 28 of file functions.php.

References Sabre\Event\Loop\instance().

Referenced by Sabre\Event\Loop\FunctionsTest\testSetInterval().

28  {
29 
30  return instance()->setInterval($cb, $timeout);
31 
32 }
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTimeout()

Sabre\Event\Loop\setTimeout ( callable  $cb,
  $timeout 
)

Executes a function after x seconds.

Parameters
callable$cb
float$timeouttimeout in seconds
Returns
void

Definition at line 12 of file functions.php.

References Sabre\Event\Loop\instance().

Referenced by Sabre\Event\Loop\FunctionsTest\testStop(), Sabre\Event\Loop\FunctionsTest\testTick(), Sabre\Event\Loop\FunctionsTest\testTimeout(), and Sabre\Event\Loop\FunctionsTest\testTimeoutOrder().

12  {
13 
14  instance()->setTimeout($cb, $timeout);
15 
16 }
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

Sabre\Event\Loop\stop ( )

Stops a running eventloop.

Returns
void

Definition at line 162 of file functions.php.

References Sabre\Event\Loop\instance().

Referenced by Sabre\Event\Loop\FunctionsTest\testStop().

162  {
163 
164  instance()->stop();
165 
166 }
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tick()

Sabre\Event\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.

Parameters
bool$block
Returns
bool

Definition at line 151 of file functions.php.

References Sabre\Event\Loop\instance().

Referenced by Sabre\Event\Loop\FunctionsTest\testTick(), and Sabre\Event\Promise\wait().

151  {
152 
153  return instance()->tick($block);
154 
155 }
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
+ Here is the call graph for this function:
+ Here is the caller graph for this function: