Initial commit

This commit is contained in:
2025-08-10 15:33:20 +02:00
commit 65e508927a
7 changed files with 526 additions and 0 deletions

36
example.php Normal file
View 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";