Completed
Push — master ( 1fa11a...2abe5b )
by Akihito
02:24
created

ActiveWorkerSet::terminate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
namespace Ackintosh\Snidel;
3
4
class ActiveWorkerSet
5
{
6
    /** @var \Ackintosh\Snidel\Worker[] */
7
    private $workers = array();
8
9
    /**
10
     * @param   \Ackintosh\Snidel\Worker
11
     * @return  void
12
     */
13
    public function add($worker)
14
    {
15
        $this->workers[$worker->getPid()] = $worker;
16
    }
17
18
    /**
19
     * @param   int     $pid
20
     * @return  void
21
     */
22
    public function delete($pid)
23
    {
24
        unset($this->workers[$pid]);
25
    }
26
27
    /**
28
     * @return  int
29
     */
30
    public function count()
31
    {
32
        return count($this->workers);
33
    }
34
35
    /**
36
     * @param   int     $sig
37
     * @return  void
38
     */
39
    public function terminate($sig)
40
    {
41
        foreach ($this->workers as $worker) {
42
            $worker->terminate($sig);
43
        }
44
    }
45
}
46