function HttpDownloader::countActiveJobs
@internal
Parameters
int|null $index For internal use only, the job id:
Return value
int number of active (queued or started) jobs
1 call to HttpDownloader::countActiveJobs()
- HttpDownloader::wait in vendor/
composer/ composer/ src/ Composer/ Util/ HttpDownloader.php - Wait for current async download jobs to complete
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ HttpDownloader.php, line 381
Class
- HttpDownloader
- @author Jordi Boggiano <j.boggiano@seld.be> @phpstan-type Request array{url: non-empty-string, options: mixed[], copyTo: string|null} @phpstan-type Job array{id: int, status: int, request: Request, sync: bool, origin: string, resolve?: callable,…
Namespace
Composer\UtilCode
public function countActiveJobs(?int $index = null) : int {
if ($this->runningJobs < $this->maxJobs) {
foreach ($this->jobs as $job) {
if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
$this->startJob($job['id']);
}
}
}
if ($this->curl) {
$this->curl
->tick();
}
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++;
}
elseif (!$job['sync']) {
unset($this->jobs[$job['id']]);
}
}
return $active;
}