Initial commit
This commit is contained in:
36
example.php
Normal file
36
example.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__."/vendor/autoload.php";
|
||||
|
||||
use function NoccyLabs\React\Utilities\defer;
|
||||
use function NoccyLabs\React\Utilities\enqueue;
|
||||
|
||||
// Yay!
|
||||
echo "Before\n";
|
||||
|
||||
// Enqueue will keep creating futureTicks() (or defers()) as each enqueued callback is
|
||||
// executed. Thus, these three enqueued operations will not clog up the futureTick
|
||||
// queue for other operations, but they will be executed one at a time with the next
|
||||
// enqueued after the first has executed.
|
||||
enqueue(function () {
|
||||
echo "Queued 1\n";
|
||||
});
|
||||
enqueue(function () {
|
||||
echo "Queued 2\n";
|
||||
});
|
||||
enqueue(function () {
|
||||
echo "Queued 3\n";
|
||||
});
|
||||
|
||||
// Defer is simply a convenient shortcut for Loop::futureTick(...). It defers execution
|
||||
// of the callback. These two will always be executed in order, as they are added
|
||||
// immediately to the futureTick queue.
|
||||
defer(function () {
|
||||
echo "Deferred1\n";
|
||||
});
|
||||
defer(function () {
|
||||
echo "Deferred2\n";
|
||||
});
|
||||
|
||||
// Loop will run after this, including the above enqueues and defers
|
||||
echo "After\n";
|
Reference in New Issue
Block a user