Skip to content

PD\Async is a PHP library using ReactPHP to perform asynchronous tasks, supporting task dependency handling and topological sorting.

License

Notifications You must be signed in to change notification settings

pardnchiu/php-async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PD\Async

PD\Async is a PHP library using ReactPHP to perform asynchronous tasks, supporting task dependency handling and topological sorting.

tag size
version download

Features

  • Asynchronous Task Execution
  • Handling of Task Dependencies
  • Ensuring correct execution order via Topological Sorting

Key Capabilities

  • Non-blocking Task Processing
  • Task Dependency Management
  • Smart Execution Ordering
  • Promise Error Handling
  • Flexible Task Configuration

Dependencies

  • react/promise - Promise/A+ for PHP
  • react/event-loop - Event Loop Library for PHP

How to Use

Install

composer require pardnchiu/async
<?php use PD\Async; $tasks = [ 'task1' => [ 'method' => function () { return 'result1'; }, 'tasks' => [], ], 'task2' => [ 'method' => function () { return 'result2'; }, 'tasks' => ['task1'], // Run after task1 ], 'task3' => [ 'method' => function () { return 'result3'; }, 'tasks' => ['task1'], // Run after task1 ], 'task4' => [ 'method' => function () { return 'result3'; }, 'tasks' => ['task2'], // Run after task2 ], ]; Async::run($tasks) ->then(function ($results) { print_r($results); }) ->catch(function ($error) { echo 'Error: ' . $error->getMessage(); });

License

This source code project is licensed under the MIT license.

Creator

邱敬幃 Pardn Chiu


©️ 2024 邱敬幃 Pardn Chiu

About

PD\Async is a PHP library using ReactPHP to perform asynchronous tasks, supporting task dependency handling and topological sorting.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages