定制 agussuroyo/async 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agussuroyo/async

最新稳定版本:1.0.0

Composer 安装命令:

composer require agussuroyo/async

包简介

A simple asynchronous process manager for PHP using pcntl.

README 文档

README

GitHub Workflow Status on master Branch

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-27