Skip to content

Commit 2a6b40d

Browse files
authored
Merge pull request #58 from reactphp-parallel/2.x-examples
[2.x] Ensure all examples are working as expected are run everything in a fiber - Part II - The quest for the missing readme update
2 parents dbc9899 + b3ca753 commit 2a6b40d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,23 @@ Just like any other `react-parallel` the limited pool will run any closure you s
2323
pool have a fixed number of threads running.
2424

2525
```php
26-
$finite = new Limited(
26+
use React\EventLoop\Loop;
27+
use ReactParallel\EventLoop\EventLoopBridge;
28+
use ReactParallel\Pool\Infinite\Infinite;
29+
use ReactParallel\Pool\Limited\Limited;
30+
use function React\Async\async;
31+
32+
$limited = new Limited(
2733
new Infinite(new EventLoopBridge(), 1), // Another pool, preferably an inifinite pool
2834
100 // The amount of threads to start and keep running
2935
);
3036
$time = time();
31-
echo 'Unix timestamp: ', $finite->run(function (int $time): int {
32-
return $time;
33-
}, [$time]), $time, PHP_EOL;
37+
38+
Loop::futureTick(async(static function () use ($limited, $time) {
39+
echo 'Unix timestamp: ', $limited->run(function (int $time): int {
40+
return $time;
41+
}, [$time]), $time, PHP_EOL;
42+
}));
3443
```
3544

3645
## License ##

0 commit comments

Comments
 (0)