1 | <?php |
||
9 | class ParallelProcess |
||
10 | { |
||
11 | protected $process; |
||
12 | protected $id; |
||
13 | protected $pid; |
||
14 | |||
15 | protected $successCallbacks = []; |
||
16 | protected $errorCallbacks = []; |
||
17 | protected $timeoutCallbacks = []; |
||
18 | |||
19 | protected $output; |
||
20 | protected $errorOutput; |
||
21 | |||
22 | protected $startTime; |
||
23 | |||
24 | public function __construct(Process $process, string $id) |
||
25 | { |
||
26 | $this->process = $process; |
||
27 | $this->id = $id; |
||
28 | } |
||
29 | |||
30 | public static function create(Process $process, string $id): self |
||
31 | { |
||
32 | return new self($process, $id); |
||
33 | } |
||
34 | |||
35 | public function then(callable $callback): self |
||
41 | |||
42 | public function catch(callable $callback): self |
||
48 | |||
49 | public function timeout(callable $callback): self |
||
55 | |||
56 | public function start(): self |
||
66 | |||
67 | public function stop(): self |
||
73 | |||
74 | public function isRunning(): bool |
||
78 | |||
79 | public function isSuccessful(): bool |
||
83 | |||
84 | public function isTerminated(): bool |
||
88 | |||
89 | public function getOutput() |
||
103 | |||
104 | public function getErrorOutput() |
||
118 | |||
119 | public function getProcess(): Process |
||
123 | |||
124 | public function getId(): string |
||
128 | |||
129 | public function getPid(): ?string |
||
133 | |||
134 | public function getCurrentExecutionTime(): float |
||
138 | |||
139 | public function triggerSuccess() |
||
155 | |||
156 | public function triggerError() |
||
157 | { |
||
168 | |||
169 | public function triggerTimeout() |
||
175 | |||
176 | protected function resolveErrorOutput(): Throwable |
||
190 | } |
||
191 |