Tags: reactphp-parallel/reactphp-parallel
Tags
Fully reworked the public facing API to utilize fibers:
From:
```php
<?php
use PackageVersions\Versions;
use React�ventLoop\Factory;
use ReactParallel\Factory as ParallelFactory;
use ReactParallel\ObjectProxy\Generated\Proxies\WyriHaximus\Metrics\Registry as RegistryProxy;
use WyriHaximus\Metrics\Label;
use function React\Promise�ll;
use WyriHaximus\React\Parallel\Finite;
use function WyriHaximus\iteratorOrArrayToArray;
use WyriHaximus\React\Parallel\ReturnThread;
use WyriHaximus\React\Parallel\FiniteWorker;
$options = getopt(
'',
[
'iterations:',
'delay::',
],
);
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$loop = Factory::create();
echo 'Loop: ', get_class($loop), PHP_EOL;
$parallelFactory = new ParallelFactory($loop);
$pool = $parallelFactory->lowLevelPool();
$loop->futureTick(static function () use ($pool, $options): void {
foreach (range(0, 7) as $i) {
$pool->run(static function (int $index, int $iterations, bool $delay): int {
for ($i = 0; $i < $iterations; $i++) {
if ($delay) {
usleep($i * 3.3);
}
echo "�[" . (30 + $index) . ";" . (40 + $index) . "m.�[0m";
}
return true;
}, [$i, (int)$options['iterations'], isset($options['delay'])]);
}
});
echo PHP_EOL, 'Loop::run()', PHP_EOL;
$loop->run();
echo PHP_EOL, 'Loop::done()', PHP_EOL;
```
To:
```php
<?php
declare(strict_types=1);
use React�ventLoop\Loop;
use ReactParallel\Factory as ParallelFactory;
use function React\Async�sync;
$options = getopt(
'',
[
'iterations:',
'delay::',
],
);
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
echo 'Loop: ', Loop::get()::class, PHP_EOL;
$parallelFactory = new ParallelFactory();
$pool = $parallelFactory->lowLevelPool();
foreach (range(0, 7) as $i) {
Loop::futureTick(async(static function () use ($i, $pool, $options): void {
$pool->run(static function (int $index, int $iterations, bool $delay): bool {
for ($i = 0; $i < $iterations; $i++) {
if ($delay) {
usleep((int) ($i * 0.3));
}
echo "�[" . (30 + $index) . ";" . (40 + $index) . "m.�[0m";
}
return true;
}, [$i, (int)$options['iterations'], isset($options['delay'])]);
}));
}
echo PHP_EOL, 'Loop::run()', PHP_EOL;
```
2.0.0
=====
- Total issues resolved: **0**
- Total pull requests resolved: **28**
- Total contributors: **3**
Dependencies 📦,Feature 🏗
------------------------
- [56: Template types](#56) thanks to @WyriHaximus
Dependencies 📦,Enhancement ✨
----------------------------
- [54: Down bump to PHP 8.1](#54) thanks to @WyriHaximus
Dependencies 📦
--------------
- [50: Bump composer/composer from 2.6.6 to 2.7.0](#50) thanks to @dependabot[bot]
- [49: PHP 8.2+](#49) thanks to @WyriHaximus
- [48: Update dependency react/http to v1.9.0 [SECURITY] - autoclosed](#48) thanks to @renovate[bot]
- [47: Update dependency react/http to v1.9.0 [SECURITY]](#47) thanks to @renovate[bot]
- [46: Update github/super-linter Docker tag to v5 - autoclosed](#46) thanks to @renovate[bot]
- [44: Update actions/cache action to v3 - autoclosed](#44) thanks to @renovate[bot]
- [43: Update JasonEtco/is-sponsor-label-action action to v2 - autoclosed](#43) thanks to @renovate[bot]
- [42: Update github/super-linter Docker tag to v2.2.2 - autoclosed](#42) thanks to @renovate[bot]
- [41: Update dependency wyrihaximus/metrics to v2 - autoclosed](#41) thanks to @renovate[bot]
- [40: Update dependency wyrihaximus/async-test-utilities to v7 - autoclosed](#40) thanks to @renovate[bot]
- [39: Update dependency react/promise to v3 - autoclosed](#39) thanks to @renovate[bot]
- [38: Update dependency ocramius/package-versions to v2 - autoclosed](#38) thanks to @renovate[bot]
- [37: Update dependency moneyphp/money to v4 - autoclosed](#37) thanks to @renovate[bot]
- [35: Update dependency react/http to v1.9.0 [SECURITY]](#35) thanks to @renovate[bot]
- [33: Update dependency ancarda/psr7-string-stream to v1.3.1 - autoclosed](#33) thanks to @renovate[bot]
- [32: Update dependency react/http to v1.9.0 [SECURITY] - autoclosed](#32) thanks to @renovate[bot]
- [27: Bump react/http from 1.2.0 to 1.3.0](#27) thanks to @dependabot[bot]
- [25: Bump react-parallel/limited-pool from 1.0.0 to 1.0.1](#25) thanks to @dependabot[bot]
- [24: Bump wyrihaximus/async-test-utilities from 3.3.2 to 3.3.3](#24) thanks to @dependabot[bot]
- [23: Bump wyrihaximus/async-test-utilities from 3.3.1 to 3.3.2](#23) thanks to @dependabot[bot]
- [22: Bump react-parallel/event-loop from 1.1.0 to 1.2.0](#22) thanks to @dependabot[bot]
- [21: Bump wyrihaximus/async-test-utilities from 3.2.0 to 3.3.1](#21) thanks to @dependabot[bot]
- [20: Bump react-parallel/infinite-pool from 2.1.0 to 2.1.2](#20) thanks to @dependabot[bot]
- [19: Bump react/http from 1.1.0 to 1.2.0](#19) thanks to @dependabot[bot]
Enhancement ✨
-------------
- [58: Update Metrics example](#58) thanks to @WyriHaximus
- [57: [2.x] Ensure all examples are up to date and working](#57) thanks to @WyriHaximus