-
Notifications
You must be signed in to change notification settings - Fork 5
/
InvokedProcessPool.php
67 lines (59 loc) · 1.43 KB
/
InvokedProcessPool.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace Illuminate\Process;
use Countable;
class InvokedProcessPool implements Countable
{
/**
* The array of invoked processes.
*
* @var array
*/
protected $invokedProcesses;
/**
* Create a new invoked process pool.
*
* @param array $invokedProcesses
* @return void
*/
public function __construct(array $invokedProcesses)
{
$this->invokedProcesses = $invokedProcesses;
}
/**
* Send a signal to each running process in the pool, returning the processes that were signalled.
*
* @param int $signal
* @return \Illuminate\Support\Collection
*/
public function signal(int $signal)
{
return $this->running()->each->signal($signal);
}
/**
* Get the processes in the pool that are still currently running.
*
* @return \Illuminate\Support\Collection
*/
public function running()
{
return collect($this->invokedProcesses)->filter->running()->values();
}
/**
* Wait for the processes to finish.
*
* @return \Illuminate\Process\ProcessPoolResults
*/
public function wait()
{
return new ProcessPoolResults(collect($this->invokedProcesses)->map->wait()->all());
}
/**
* Get the total number of processes.
*
* @return int
*/
public function count(): int
{
return count($this->invokedProcesses);
}
}