1 | <?php |
||
7 | class Pool implements \ArrayAccess |
||
8 | { |
||
9 | protected $runtime; |
||
10 | protected $concurrency = 20; |
||
11 | protected $tasksPerProcess = 1; |
||
12 | |||
13 | /** @var \Spatie\Async\Task[] */ |
||
14 | protected $tasks = []; |
||
15 | |||
16 | /** @var \Spatie\Async\Process[] */ |
||
17 | protected $queue = []; |
||
18 | /** @var \Spatie\Async\Process[] */ |
||
19 | protected $inProgress = []; |
||
20 | /** @var \Spatie\Async\Process[] */ |
||
21 | protected $finished = []; |
||
22 | /** @var \Spatie\Async\Process[] */ |
||
23 | protected $failed = []; |
||
24 | |||
25 | public function __construct() |
||
29 | |||
30 | /** |
||
31 | * @return static |
||
32 | */ |
||
33 | public static function create() |
||
37 | |||
38 | public function concurrency(int $concurrency): self |
||
44 | |||
45 | public function tasksPerProcess(int $tasksPerProcess): self |
||
51 | |||
52 | public function maximumExecutionTime(int $maximumExecutionTime): self |
||
58 | |||
59 | public function notify(): void |
||
79 | |||
80 | public function add($process): ?Process |
||
98 | |||
99 | public function run(Process $process): Process |
||
103 | |||
104 | public function wait(): void |
||
138 | |||
139 | public function queueTask(Task $task): void |
||
145 | |||
146 | public function queue(Process $process): void |
||
152 | |||
153 | public function inProgress(Process $process): void |
||
159 | |||
160 | public function finished(Process $process): void |
||
168 | |||
169 | public function failed(Process $process): void |
||
177 | |||
178 | public function offsetExists($offset) |
||
184 | |||
185 | public function offsetGet($offset) |
||
189 | |||
190 | public function offsetSet($offset, $value) |
||
194 | |||
195 | public function offsetUnset($offset) |
||
199 | |||
200 | protected function scheduleTasks(?int $amount = null): void |
||
217 | |||
218 | /** |
||
219 | * @return \Spatie\Async\Process[] |
||
220 | */ |
||
221 | public function getFinished(): array |
||
225 | |||
226 | /** |
||
227 | * @return \Spatie\Async\Process[] |
||
228 | */ |
||
229 | public function getFailed(): array |
||
233 | } |
||
234 |