2016-12-29 19:16:04 -06:00
|
|
|
<?php
|
2016-08-21 10:33:39 -05:00
|
|
|
|
2016-08-23 16:47:40 -05:00
|
|
|
namespace Amp\Parallel\Worker\Internal;
|
2016-08-21 10:33:39 -05:00
|
|
|
|
2017-03-16 17:03:59 -05:00
|
|
|
use Amp\Promise;
|
2017-05-18 09:51:31 +02:00
|
|
|
use Amp\Success;
|
2016-08-21 10:33:39 -05:00
|
|
|
|
2017-07-27 23:49:20 -05:00
|
|
|
/** @internal */
|
2016-09-07 11:38:46 -05:00
|
|
|
class TaskSuccess extends TaskResult {
|
2016-08-21 10:33:39 -05:00
|
|
|
/** @var mixed Result of task. */
|
|
|
|
private $result;
|
2017-05-18 09:51:31 +02:00
|
|
|
|
2016-08-21 10:33:39 -05:00
|
|
|
public function __construct(string $id, $result) {
|
2016-09-07 11:38:46 -05:00
|
|
|
parent::__construct($id);
|
2016-08-21 10:33:39 -05:00
|
|
|
$this->result = $result;
|
|
|
|
}
|
2017-05-18 09:51:31 +02:00
|
|
|
|
2016-11-14 17:43:44 -06:00
|
|
|
public function promise(): Promise {
|
2016-08-21 10:33:39 -05:00
|
|
|
return new Success($this->result);
|
|
|
|
}
|
|
|
|
}
|