agussuroyo/async
最新稳定版本:1.0.0
Composer 安装命令:
composer require agussuroyo/async
包简介
A simple asynchronous process manager for PHP using pcntl.
README 文档
README
A lightweight and efficient PHP package to manage asynchronous processes with a configurable process limit.
Installation
Install via Composer:
composer require agussuroyo/async
Features
- Asynchronous process execution with
pcntl_fork - Configurable maximum number of parallel processes
- Automatic CPU core detection for optimal performance
- Efficient child process management
Usage
Basic Example
use AgusSuroyo\Async\Async; $async = new Async(); $async->run(function () { sleep(2); echo "Process 1 done\n"; }); $async->run(function () { sleep(3); echo "Process 2 done\n"; }); $async->wait();
Setting Maximum Concurrent Processes
$async = new Async(2); // Limit to 2 concurrent processes
Dynamic Max Process Control
$async = new Async(); $async->max(4); // Adjust max processes at runtime
Testing
Run the tests using PHPUnit:
vendor/bin/phpunit
Contributing
Contributions are welcome! Please submit a pull request or open an issue.
License
This package is open-source and available under the MIT License.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-27