1 | <?php |
||
10 | class ParallelProcess implements Runnable |
||
11 | { |
||
12 | protected $process; |
||
13 | protected $id; |
||
14 | protected $pid; |
||
15 | |||
16 | protected $output; |
||
17 | protected $errorOutput; |
||
18 | |||
19 | protected $startTime; |
||
20 | |||
21 | use ProcessCallbacks; |
||
22 | |||
23 | public function __construct(Process $process, int $id) |
||
28 | |||
29 | public static function create(Process $process, int $id): self |
||
33 | |||
34 | public function start(): self |
||
44 | |||
45 | public function stop(): self |
||
51 | |||
52 | public function isRunning(): bool |
||
56 | |||
57 | public function isSuccessful(): bool |
||
61 | |||
62 | public function isTerminated(): bool |
||
66 | |||
67 | /** |
||
68 | * Flush the process's stdout output buffer (it is then kept by Symfony's copy of stdout). |
||
69 | * Due to stdout output buffering, it is possible for a program to hang once it fills the buffer for stdout. At this point, the program wouldn't do anything else. By forcing a check on the program's output, we can ensure that we actually read through the output buffer. |
||
70 | */ |
||
71 | public function seekOutput() |
||
75 | |||
76 | public function getOutput() |
||
90 | |||
91 | public function getErrorOutput() |
||
105 | |||
106 | public function getProcess(): Process |
||
110 | |||
111 | public function getId(): int |
||
115 | |||
116 | public function getPid(): ?int |
||
120 | |||
121 | public function getCurrentExecutionTime(): float |
||
125 | |||
126 | protected function resolveErrorOutput(): Throwable |
||
140 | } |
||
141 |