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) |
|
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | 8 | public function setWorkerInstance(WorkerInterface $worker) |
|
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | 1 | public function rebuild() |
|
134 | |||
135 | /** |
||
136 | * {@inheritdoc} |
||
137 | */ |
||
138 | 5 | public function spawn() |
|
151 | |||
152 | /** |
||
153 | * {@inheritdoc} |
||
154 | */ |
||
155 | 2 | public function kill($pid = null) |
|
174 | |||
175 | /** |
||
176 | * {@inheritdoc} |
||
177 | */ |
||
178 | 1 | public function killAll() |
|
184 | |||
185 | /** |
||
186 | * {@inheritdoc} |
||
187 | */ |
||
188 | 3 | public function boot() |
|
204 | |||
205 | /** |
||
206 | * {@inheritdoc} |
||
207 | */ |
||
208 | public function ping() |
||
218 | |||
219 | /** |
||
220 | * {@inheritdoc} |
||
221 | */ |
||
222 | 7 | public function getWorkers() |
|
226 | |||
227 | /** |
||
228 | * {@inheritdoc} |
||
229 | */ |
||
230 | 9 | public function setOutput(OutputInterface $output) |
|
234 | |||
235 | /** |
||
236 | * {@inheritdoc} |
||
237 | */ |
||
238 | 6 | public function getOutput() |
|
246 | } |
||
247 |