1
0
mirror of https://github.com/danog/amp.git synced 2024-12-02 09:27:46 +01:00

Use \Closure in launch

This commit is contained in:
Niklas Keller 2021-12-02 18:49:00 +01:00
parent 6d3bf39a7e
commit bdce2f0896

View File

@ -7,16 +7,16 @@ use Revolt\EventLoop;
use Revolt\EventLoop\UnsupportedFeatureException; use Revolt\EventLoop\UnsupportedFeatureException;
/** /**
* Creates a new fiber asynchronously using the given callable, returning a Future that is completed with the * Creates a new fiber asynchronously using the given closure, returning a Future that is completed with the
* eventual return value of the passed function or will fail if the callback throws an exception. * eventual return value of the passed function or will fail if the closure throws an exception.
* *
* @template T * @template T
* *
* @param callable():T $callback * @param \Closure():T $closure
* *
* @return Future<T> * @return Future<T>
*/ */
function launch(callable $callback): Future function launch(\Closure $closure): Future
{ {
static $run = null; static $run = null;
@ -30,7 +30,7 @@ function launch(callable $callback): Future
$state = new Internal\FutureState; $state = new Internal\FutureState;
EventLoop::queue($run, $state, $callback); EventLoop::queue($run, $state, $closure);
return new Future($state); return new Future($state);
} }