mirror of
https://github.com/danog/parallel.git
synced 2024-12-13 17:47:32 +01:00
26 lines
558 B
PHP
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;
|
|
}
|
|
}
|