Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": {
"php": "^7.4",
"ext-parallel": "*",
"react-parallel/contracts": "^1.0",
"react-parallel/event-loop": "^1.0",
"react-parallel/infinite-pool": "^2.0",
"react-parallel/limited-pool": "dev-master",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Closure;
use React\EventLoop\LoopInterface;
use React\Promise\PromiseInterface;
use ReactParallel\Contracts\LowLevelPoolInterface;
use ReactParallel\EventLoop\EventLoopBridge;
use ReactParallel\Pool\Infinite\Infinite;
use ReactParallel\Pool\Limited\Limited;
Expand All @@ -17,9 +18,9 @@
final class Factory
{
private LoopInterface $loop;
private ?EventLoopBridge $eventLoopBridge = null;
private ?Infinite $infinitePool = null;
private ?StreamsFactory $streamsFactory = null;
private ?EventLoopBridge $eventLoopBridge = null;
private ?LowLevelPoolInterface $infinitePool = null;
private ?StreamsFactory $streamsFactory = null;

public function __construct(LoopInterface $loop)
{
Expand Down Expand Up @@ -54,10 +55,10 @@ public function streams(): StreamsFactory
*/
public function call(Closure $closure, array $args = []): PromiseInterface
{
return $this->infinitePool()->run($closure, $args);
return $this->lowLevelPool()->run($closure, $args);
}

public function infinitePool(): Infinite
public function lowLevelPool(): LowLevelPoolInterface
{
if ($this->infinitePool === null) {
$this->infinitePool = new Infinite($this->loop, $this->eventLoopBridge(), ONE);
Expand All @@ -68,6 +69,6 @@ public function infinitePool(): Infinite

public function limitedPool(int $threadCount): Limited
{
return Limited::createWithPool($this->infinitePool(), $threadCount);
return Limited::createWithPool($this->lowLevelPool(), $threadCount);
}
}
4 changes: 2 additions & 2 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public function call(): void
/**
* @test
*/
public function infinitePool(): void
public function lowLevelPool(): void
{
$factory = new Factory(EventLoopFactory::create());

$pool = $factory->infinitePool();
$pool = $factory->lowLevelPool();
self::assertSame(666, $this->await($pool->run(function (int $a, int $b): int {
return $a * $b;
}, [333, 2]), $factory->loop()));
Expand Down