Skip to content

ConcurrencyHelper is a library for easily and efficiently running any callable via multiple parallel PHP instances.

License

Notifications You must be signed in to change notification settings

bettergistco/ConcurrencyHelper

Repository files navigation

ConcurrencyHelper

ConcurrencyHelper is a library for easily and efficiently running any callable via multiple parallel PHP instances.

It's aim is to substantially simplify massively parallelized operations.

Notable use cases include the Bettergist Collector project, which uses ConcurrencyHelper to massively parallize the downloads of every www.Packagist.org package, using 50-200 PHP processes.

This library requires the ext-pcntl extension.

https://github.com/bettergistco/ConcurrencyHelper

Usage

```php
$myParallelizedFunction = function (int $childNumber, array $packages, $optionalExtraParameter) {
echo "Thread $childNumber: " . implode(', ', $packages) . " of $optionalExtraParameter\n";

    sleep($childNumber * 1);

    echo "Finished Thread $childNumber.\n";
};

$states = [
'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado',
'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho',
];

$runner = new BettergistCollective\ConcurrencyHelper\ConcurrencyHelper();
$runner->concurrentlyRun($states, 6, $myParallelizedFunction, [count($states)]);
```

Installation

Via Composer

$ composer require phpexperts/conciseuuid

This library requires the ext-pcntl extension.

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ phpunit

Contributing

Please take a look at contributing.md if you want to make improvements.

Credits

  • Theodore R. Smith

License

MIT license. Please see the license file for more information.

About

ConcurrencyHelper is a library for easily and efficiently running any callable via multiple parallel PHP instances.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages