21 public function __construct(
22 private readonly
int $threads = 1,
26 public function runInParallel( callable $mainThread, callable $forkThread ):
void {
29 if ( function_exists(
'pcntl_fork' ) ) {
34 MediaWikiServices::resetChildProcessServices();
37 } elseif ( $pid === -1 ) {
43 $this->pids[$pid] =
true;
46 if ( count( $this->pids ) >= $this->threads ) {
48 $pid = pcntl_wait( $status );
49 unset( $this->pids[$pid] );