37 lines
1011 B
PHP
37 lines
1011 B
PHP
<?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";
|