mirror of
https://github.com/danog/amp.git
synced 2024-12-11 17:09:40 +01:00
Update for Fiber constructor change
This commit is contained in:
parent
7c7e0ea554
commit
80ea42bdcf
@ -53,7 +53,7 @@ namespace Amp
|
||||
{
|
||||
$placeholder = new Internal\Placeholder;
|
||||
|
||||
$fiber = \Fiber::create(static function () use ($placeholder, $callback, $args): void {
|
||||
$fiber = new \Fiber(static function () use ($placeholder, $callback, $args): void {
|
||||
try {
|
||||
$placeholder->resolve($callback(...$args));
|
||||
} catch (\Throwable $exception) {
|
||||
@ -90,7 +90,7 @@ namespace Amp
|
||||
*/
|
||||
function defer(callable $callback, mixed ...$args): void
|
||||
{
|
||||
$fiber = \Fiber::create(static function () use ($callback, $args): void {
|
||||
$fiber = new \Fiber(static function () use ($callback, $args): void {
|
||||
try {
|
||||
$callback(...$args);
|
||||
} catch (\Throwable $exception) {
|
||||
|
@ -3,11 +3,9 @@
|
||||
final class Fiber
|
||||
{
|
||||
/**
|
||||
* @param callable $callback Function to invoke when running the fiber.
|
||||
*
|
||||
* @return self A new Fiber that has not been started.
|
||||
* @param callable $callback Function to invoke when starting the fiber.
|
||||
*/
|
||||
public static function create(callable $callback): self { }
|
||||
public function __construct(callable $callback) { }
|
||||
|
||||
/**
|
||||
* Starts execution of the fiber. Returns when the fiber suspends or terminates.
|
||||
@ -47,6 +45,11 @@ final class Fiber
|
||||
*/
|
||||
public function throw(Throwable $exception): void { }
|
||||
|
||||
/**
|
||||
* @return bool True if the fiber has been started.
|
||||
*/
|
||||
public function isStarted(): bool { }
|
||||
|
||||
/**
|
||||
* @return bool True if the fiber is suspended.
|
||||
*/
|
||||
@ -87,9 +90,4 @@ final class Fiber
|
||||
* @throws Throwable Exception provided to {@see Fiber::throw()}.
|
||||
*/
|
||||
public static function suspend(FiberScheduler $scheduler): mixed { }
|
||||
|
||||
/**
|
||||
* Private constructor to force use of {@see create()}.
|
||||
*/
|
||||
private function __construct() { }
|
||||
}
|
||||
|
@ -27,12 +27,17 @@ class ReflectionFiber
|
||||
public function getTrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT): array { }
|
||||
|
||||
/**
|
||||
* @return bool True if the fiber is currently suspended, false otherwise.
|
||||
* @return bool True if the fiber has been started.
|
||||
*/
|
||||
public function isStarted(): bool { }
|
||||
|
||||
/**
|
||||
* @return bool True if the fiber is currently suspended.
|
||||
*/
|
||||
public function isSuspended(): bool { }
|
||||
|
||||
/**
|
||||
* @return bool True if the fiber is currently running, false otherwise.
|
||||
* @return bool True if the fiber is currently running.
|
||||
*/
|
||||
public function isRunning(): bool { }
|
||||
|
||||
|
@ -4,13 +4,11 @@ class ReflectionFiberScheduler extends ReflectionFiber
|
||||
{
|
||||
/**
|
||||
* @param FiberScheduler $scheduler
|
||||
*
|
||||
* @throws FiberError If the {@see FiberScheduler} has not been used to suspend a fiber.
|
||||
*/
|
||||
public function __construct(FiberScheduler $scheduler) { }
|
||||
|
||||
/**
|
||||
* @return FiberScheduler The instance used to create the fiber.
|
||||
*/
|
||||
public function getFiberScheduler(): FiberScheduler { }
|
||||
public function getScheduler(): FiberScheduler { }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user