1
0
mirror of https://github.com/danog/amp.git synced 2024-12-04 02:17:54 +01:00
amp/stubs/Fiber.php

61 lines
1.8 KiB
PHP
Raw Normal View History

2020-09-24 18:52:22 +02:00
<?php
final class Fiber
{
/**
* Can only be called within {@see FiberScheduler::run()}.
*
* @param callable $callback Function to invoke when starting the Fiber.
* @param mixed ...$args Function arguments.
*/
public static function run(callable $callback, mixed ...$args): void { }
/**
* Private constructor to force use of {@see run()}.
*/
private function __construct() { }
/**
* @return bool True if the fiber is suspended.
*/
public function isSuspended(): bool { }
/**
* @return bool True if the fiber is currently running.
*/
public function isRunning(): bool { }
/**
* @return bool True if the fiber has completed execution.
*/
public function isTerminated(): bool { }
/**
* Resumes the fiber, returning the given value from {@see Fiber::suspend()}.
*
* @param mixed $value
*/
public function resume(mixed $value = null): void { }
/**
* Throws the given exception into the fiber from {@see Fiber::suspend()}.
*
* @param Throwable $exception
*/
public function throw(Throwable $exception): void { }
/**
* Suspend execution of the fiber. The Fiber object is provided as the first argument to the given callback.
* The fiber may be resumed with {@see Fiber::resume()} or {@see Fiber::throw()}.
2020-09-24 18:52:22 +02:00
*
* @param callable(Fiber):void $enqueue
2020-09-24 18:52:22 +02:00
* @param FiberScheduler $scheduler
*
* @return mixed Value provided to {@see Fiber::resume()}.
2020-09-24 18:52:22 +02:00
*
* @throws FiberError Thrown if within {@see FiberScheduler::run()}.
* @throws Throwable Exception provided to {@see Fiber::throw()}.
2020-09-24 18:52:22 +02:00
*/
public static function suspend(callable $enqueue, FiberScheduler $scheduler): mixed { }
2020-09-24 18:52:22 +02:00
}