fiber\go()
Start a task concurrently and return an opaque awaitable.
function fiber\go(callable $f, mixed ...$args): object
Behaviour
Must be called inside run(); otherwise it throws NotInRunException. The awaitable may only be passed to await(), await_all() and await_any(). Its concrete type depends on the adapter (a Fiber, a Future, a promise) and calling methods on it is not portable.
The current \Scope is captured at go() and the task runs inside it. An exception from a task that nobody awaits goes to the adapter's unhandled-error mechanism; the enclosing run() rethrows the first such exception when it ends.
Example
<?php
require __DIR__ . '/vendor/autoload.php';
use function fiber\{run, go, await, sleep};
run(function () {
$slow = go(function () { sleep(0.2); return 'slow'; });
$fast = go(fn() => 'fast');
echo await($fast), "\n", await($slow), "\n";
});