mirror of
https://github.com/danog/parallel.git
synced 2024-12-02 09:37:57 +01:00
29 lines
575 B
PHP
29 lines
575 B
PHP
<?php
|
|
|
|
namespace Amp\Parallel\Test\Worker\Fixtures;
|
|
|
|
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;
|
|
}
|
|
}
|