thenlabs / tick-async
1.0.x-dev
2022-01-03 15:30 UTC
Requires
- thenlabs/task-loop: 2.0.x-dev
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.2
- thenlabs/pyramidal-tests: 2.0.x-dev
This package is auto-updated.
Last update: 2024-08-29 06:07:23 UTC
README
基于滴答的异步任务。
如果您喜欢这个项目,请给我们一个 ⭐。
安装。
$ composer require thenlabs/task-loop 2.0.x-dev thenlabs/tick-async 1.0.x-dev
该项目尚未包含稳定版本。
使用。
待办事项
示例
<?php declare(ticks=1); require __DIR__.'/vendor/autoload.php'; use function ThenLabs\TickAsync\async; async(function () { for ($i = 1; $i <= 15; $i++) { echo "async: {$i}\n"; yield; } return; }); for ($i = 1; $i <= 5; $i++) { echo "main: {$i}\n"; } echo "bye\n";
结果
async: 1
main: 1
async: 2
main: 2
async: 3
main: 3
async: 4
main: 4
async: 5
main: 5
async: 6
async: 7
bye
async: 8
async: 9
async: 10
async: 11
async: 12
async: 13
async: 14
async: 15