fiber\sleep()
Suspend the current fiber without blocking others.
function fiber\sleep(float $seconds): void
Behaviour
Throws NotInRunException outside run(). It may throw CancelledException when the owning loop cancels the task; loops implement that interface on their own exception class.
Example
<?php
require __DIR__ . '/vendor/autoload.php';
use function fiber\{run, go, await_all, sleep};
run(function () {
$t = microtime(true);
await_all([go(fn() => sleep(0.2)), go(fn() => sleep(0.2))]);
echo round(microtime(true) - $t, 1), " s for two 0.2 s sleeps\n";
});