Skip to content

Commit f8b60d6

Browse files
feat: Make pool size a setting per job queue
When a child process is assigned a task, the pool is restocked to this amount. So this is the number of idle processes at any time. The total number of processes can be higher if there are busy ones.
1 parent 6271120 commit f8b60d6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Classes/Worker.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use function array_shift;
1616
use function fputs;
1717

18+
use function max;
19+
1820
use const STDERR;
1921
use const STDOUT;
2022

@@ -30,9 +32,11 @@ final class Worker
3032
private array $pool = [];
3133

3234
/**
33-
* A pool size of 1 means one standby while 1 is working.
35+
* When a child process is assigned a task, the pool is restocked to this
36+
* amount. So this is the number of idle processes at any time. The total
37+
* number of processes can be higher if there are busy ones.
3438
*/
35-
protected int $poolSize = 1;
39+
private readonly int $poolSize;
3640

3741
public function __construct(
3842
protected readonly string $command,
@@ -42,6 +46,7 @@ public function __construct(
4246
protected readonly Lock $lock
4347
) {
4448
$this->loop = EventLoop\Loop::get();
49+
$this->poolSize = max(0, (int) ($queueSettings['poolSize'] ?? 1));
4550
}
4651

4752
public function prepare(): void

0 commit comments

Comments
 (0)