File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ public function __construct(
4646
4747 public function prepare (): void
4848 {
49- $ this ->cleanPool ( );
49+ $ this ->fillPool ( $ this -> poolSize );
5050
5151 $ this ->output = new ConsoleOutput ();
5252 $ this ->output ->outputLine ('Watching queue <b>"%s"</b> ' , [$ this ->queue ->getName ()]);
@@ -120,7 +120,7 @@ private function createProcess(): Process
120120
121121 private function runFromPool (string $ messageCacheIdentifier ): Process
122122 {
123- $ this ->cleanPool ();
123+ $ this ->fillPool ( $ this -> poolSize + 1 ); // Overfill
124124 $ process = array_shift ($ this ->pool );
125125 assert ($ process instanceof Process);
126126
@@ -134,13 +134,14 @@ private function runFromPool(string $messageCacheIdentifier): Process
134134 return $ process ;
135135 }
136136
137- private function cleanPool ( ): void
137+ private function fillPool ( int $ poolSize ): void
138138 {
139+ $ poolSize = max ($ poolSize , 0 );
139140 $ this ->pool = array_filter (
140141 $ this ->pool ,
141142 fn (Process $ process ) => $ process ->isRunning ()
142143 );
143- while (count ($ this ->pool ) < $ this -> poolSize ) {
144+ while (count ($ this ->pool ) < $ poolSize ) {
144145 $ this ->pool [] = $ this ->createProcess ();
145146 }
146147 }
You can’t perform that action at this time.
0 commit comments