Allow fetching the http downloader and process executor from the loop
parent
e537ae953e
commit
7917a7e757
|
@ -21,22 +21,40 @@ use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
*/
|
*/
|
||||||
class Loop
|
class Loop
|
||||||
{
|
{
|
||||||
|
/** @var HttpDownloader */
|
||||||
private $httpDownloader;
|
private $httpDownloader;
|
||||||
|
/** @var ProcessExecutor|null */
|
||||||
private $processExecutor;
|
private $processExecutor;
|
||||||
|
/** @var Promise[]|null */
|
||||||
private $currentPromises;
|
private $currentPromises;
|
||||||
|
|
||||||
public function __construct(HttpDownloader $httpDownloader = null, ProcessExecutor $processExecutor = null)
|
public function __construct(HttpDownloader $httpDownloader, ProcessExecutor $processExecutor = null)
|
||||||
{
|
{
|
||||||
$this->httpDownloader = $httpDownloader;
|
$this->httpDownloader = $httpDownloader;
|
||||||
if ($this->httpDownloader) {
|
|
||||||
$this->httpDownloader->enableAsync();
|
$this->httpDownloader->enableAsync();
|
||||||
}
|
|
||||||
$this->processExecutor = $processExecutor;
|
$this->processExecutor = $processExecutor;
|
||||||
if ($this->processExecutor) {
|
if ($this->processExecutor) {
|
||||||
$this->processExecutor->enableAsync();
|
$this->processExecutor->enableAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return HttpDownloader
|
||||||
|
*/
|
||||||
|
public function getHttpDownloader()
|
||||||
|
{
|
||||||
|
return $this->httpDownloader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ProcessExecutor|null
|
||||||
|
*/
|
||||||
|
public function getProcessExecutor()
|
||||||
|
{
|
||||||
|
return $this->processExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
public function wait(array $promises, ProgressBar $progress = null)
|
public function wait(array $promises, ProgressBar $progress = null)
|
||||||
{
|
{
|
||||||
/** @var \Exception|null */
|
/** @var \Exception|null */
|
||||||
|
|
Loading…
Reference in New Issue