1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 17:52:14 +01:00
parallel/test/Worker/TestTask.php
2017-12-05 18:37:33 -06:00

26 lines
558 B
PHP

<?php
namespace Amp\Parallel\Test\Worker;
use Amp\Delayed;
use Amp\Parallel\Worker\Environment;
use Amp\Parallel\Worker\Task;
class TestTask implements Task {
private $returnValue;
private $delay = 0;
public function __construct($returnValue, int $delay = 0) {
$this->returnValue = $returnValue;
$this->delay = $delay;
}
public function run(Environment $environment) {
if ($this->delay) {
return new Delayed($this->delay, $this->returnValue);
}
return $this->returnValue;
}
}