23 public function __construct(
int $threads = 1 ) {
24 $this->threads = $threads;
27 public function runInParallel( callable $mainThread, callable $forkThread ):
void {
30 if ( function_exists(
'pcntl_fork' ) ) {
35 MediaWikiServices::resetChildProcessServices();
38 } elseif ( $pid === -1 ) {
44 $this->pids[$pid] =
true;
47 if ( count( $this->pids ) >= $this->threads ) {
49 $pid = pcntl_wait( $status );
50 unset( $this->pids[$pid] );