1
0
mirror of https://github.com/danog/amp.git synced 2024-12-12 09:29:45 +01:00
amp/stubs/Fiber.php

32 lines
1.1 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 { }
/**
2020-11-05 18:29:31 +01:00
* Suspend execution of the fiber. A Continuation object is provided as the first argument to the given callback.
* The fiber may be resumed with {@see Continuation::resume()} or {@see Continuation::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
*
2020-11-05 18:29:31 +01:00
* @return mixed Value provided to {@see Continuation::resume()}.
2020-09-24 18:52:22 +02:00
*
* @throws FiberError Thrown if within {@see FiberScheduler::run()}.
2020-11-05 18:29:31 +01:00
* @throws Throwable Exception provided to {@see Continuation::throw()}.
2020-09-24 18:52:22 +02:00
*/
public static function suspend(callable $enqueue, FiberScheduler $scheduler): mixed { }
2020-11-05 18:29:31 +01:00
/**
* Private constructor to force use of {@see run()}.
*/
private function __construct() { }
2020-09-24 18:52:22 +02:00
}