1 | <?php |
||
29 | class Pool implements PoolInterface, OutputableInterface |
||
30 | { |
||
31 | /** |
||
32 | * Default amount of workers to spawn |
||
33 | * |
||
34 | * @var int |
||
35 | */ |
||
36 | const DEFAULT_WORKER_COUNT = 1; |
||
37 | |||
38 | /** |
||
39 | * Immutable. Number of workers this pool maintain |
||
40 | * |
||
41 | * @var int |
||
42 | */ |
||
43 | protected $numberOfWorkers; |
||
44 | |||
45 | /** |
||
46 | * Pool of worker objects |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $workers = array(); |
||
51 | |||
52 | /** |
||
53 | * @var WorkerInterface |
||
54 | */ |
||
55 | protected $workerInstance; |
||
56 | |||
57 | /** |
||
58 | * @var OutputInterface |
||
59 | */ |
||
60 | protected $output; |
||
61 | |||
62 | /** |
||
63 | * Timestamp of when the pool first started |
||
64 | * |
||
65 | * @var |
||
66 | */ |
||
67 | protected $started; |
||
68 | |||
69 | /** |
||
70 | * Pool constructor. |
||
71 | * |
||
72 | * @param null $numberOfWorkers |
||
73 | */ |
||
74 | 9 | public function __construct($numberOfWorkers = null) |
|
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | 8 | public function add(WorkerInterface $worker) |
|
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | 8 | public function setWorkerInstance(WorkerInterface $worker) |
|
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | 1 | public function rebuild() |
|
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | 5 | public function spawn() |
|
150 | |||
151 | /** |
||
152 | * {@inheritdoc} |
||
153 | */ |
||
154 | 2 | public function kill($pid = null) |
|
173 | |||
174 | /** |
||
175 | * {@inheritdoc} |
||
176 | */ |
||
177 | 1 | public function killAll() |
|
183 | |||
184 | /** |
||
185 | * {@inheritdoc} |
||
186 | */ |
||
187 | 3 | public function boot() |
|
203 | |||
204 | /** |
||
205 | * {@inheritdoc} |
||
206 | */ |
||
207 | public function ping() |
||
217 | |||
218 | /** |
||
219 | * {@inheritdoc} |
||
220 | */ |
||
221 | 7 | public function getWorkers() |
|
225 | |||
226 | /** |
||
227 | * {@inheritdoc} |
||
228 | */ |
||
229 | 9 | public function setOutput(OutputInterface $output) |
|
233 | |||
234 | /** |
||
235 | * {@inheritdoc} |
||
236 | */ |
||
237 | 2 | public function getOutput() |
|
245 | } |
||
246 |