innmind / async-time-warp
此包已被废弃且不再维护。作者建议使用innmind/mantle包代替。
1.0.0
2023-02-11 12:48 UTC
Requires
- php: ~8.1
- innmind/mantle: ~1.0
- innmind/time-warp: ^3.0
Requires (Dev)
- innmind/black-box: ~4.10
- innmind/coding-standard: ~2.0
- phpunit/phpunit: ~9.0
- vimeo/psalm: ~4.30
This package is auto-updated.
Last update: 2023-11-06 06:41:05 UTC
README
这是innmind/time-warp
的异步实现,允许在挂起当前进程时切换到另一个任务。
安装
composer require innmind/async-time-warp
用法
use Innmind\Async\TimeWarp\Halt; use Innmind\TimeContinuum\Earth\{ Clock, Period\Second, }; use Innmind\Mantle\{ Source\Predetermined, Suspend, Forerunner, }; $clock = new Clock; $source = Predetermined::of( static function(Suspend $suspend) use ($clock) { $halt = Halt::of($clock, $suspend); $halt(new Second(2)); echo 'World !'; }, static function(Suspend $suspend) use ($clock) { $halt = Halt::of($clock, $suspend); $halt(new Second(1)); echo 'Hello '; }, ); Forerunner::of($clock)(null, $source); // will print "Hello World !" in 2 seconds