function ProcessExecutor::countActiveJobs
@internal
Parameters
?int $index job id:
Return value
int number of active (queued or started) jobs
1 call to ProcessExecutor::countActiveJobs()
- ProcessExecutor::wait in vendor/
composer/ composer/ src/ Composer/ Util/ ProcessExecutor.php
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ ProcessExecutor.php, line 384
Class
- ProcessExecutor
- @author Robert Schönthal <seroscho@googlemail.com> @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\UtilCode
public function countActiveJobs($index = null) : int {
// tick
foreach ($this->jobs as $job) {
if ($job['status'] === self::STATUS_STARTED) {
if (!$job['process']->isRunning()) {
call_user_func($job['resolve'], $job['process']);
}
$job['process']->checkTimeout();
}
if ($this->runningJobs < $this->maxJobs) {
if ($job['status'] === self::STATUS_QUEUED) {
$this->startJob($job['id']);
}
}
}
if (null !== $index) {
return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
}
$active = 0;
foreach ($this->jobs as $job) {
if ($job['status'] < self::STATUS_COMPLETED) {
$active++;
}
else {
unset($this->jobs[$job['id']]);
}
}
return $active;
}