1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 21:31:18 +01:00

Reduce nesting

This commit is contained in:
Aaron Piotrowski 2020-11-28 23:31:27 -06:00
parent a673c80fde
commit 0c031e7c90
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -49,13 +49,15 @@ namespace Amp
{
$placeholder = new Internal\Placeholder;
Loop::defer(static fn() => \Fiber::create(static function () use ($placeholder, $callback, $args): void {
$fiber = \Fiber::create(static function () use ($placeholder, $callback, $args): void {
try {
$placeholder->resolve($callback(...$args));
} catch (\Throwable $exception) {
$placeholder->fail($exception);
}
})->start());
});
Loop::defer(static fn() => $fiber->start());
return new Internal\PrivatePromise($placeholder);
}