| @@ 11-81 (lines=71) @@ | ||
| 8 | * @package Thruster\Component\EventLoop |
|
| 9 | * @author Aurimas Niekis <[email protected]> |
|
| 10 | */ |
|
| 11 | class Child |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @var EventLoop |
|
| 15 | */ |
|
| 16 | protected $loop; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @var int |
|
| 20 | */ |
|
| 21 | protected $pid; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @var callable |
|
| 25 | */ |
|
| 26 | protected $callback; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @var int |
|
| 30 | */ |
|
| 31 | protected $priority; |
|
| 32 | ||
| 33 | public function __construct( |
|
| 34 | EventLoop $loop, |
|
| 35 | int $pid, |
|
| 36 | callable $callback, |
|
| 37 | int $priority = 0 |
|
| 38 | ) { |
|
| 39 | $this->loop = $loop; |
|
| 40 | $this->pid = $pid; |
|
| 41 | $this->callback = $callback; |
|
| 42 | $this->priority = $priority; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @return EventLoop |
|
| 47 | */ |
|
| 48 | public function getLoop() |
|
| 49 | { |
|
| 50 | return $this->loop; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return int |
|
| 55 | */ |
|
| 56 | public function getPid() |
|
| 57 | { |
|
| 58 | return $this->pid; |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @return callable |
|
| 63 | */ |
|
| 64 | public function getCallback() |
|
| 65 | { |
|
| 66 | return $this->callback; |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @return int |
|
| 71 | */ |
|
| 72 | public function getPriority() |
|
| 73 | { |
|
| 74 | return $this->priority; |
|
| 75 | } |
|
| 76 | ||
| 77 | public function cancel() |
|
| 78 | { |
|
| 79 | $this->loop->cancelChild($this); |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||
| @@ 11-81 (lines=71) @@ | ||
| 8 | * @package Thruster\Component\EventLoop |
|
| 9 | * @author Aurimas Niekis <[email protected]> |
|
| 10 | */ |
|
| 11 | class Signal |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @var EventLoop |
|
| 15 | */ |
|
| 16 | protected $loop; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @var int |
|
| 20 | */ |
|
| 21 | protected $signalNo; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @var callable |
|
| 25 | */ |
|
| 26 | protected $callback; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @var int |
|
| 30 | */ |
|
| 31 | protected $priority; |
|
| 32 | ||
| 33 | public function __construct( |
|
| 34 | EventLoop $loop, |
|
| 35 | int $signalNo, |
|
| 36 | callable $callback, |
|
| 37 | int $priority = 0 |
|
| 38 | ) { |
|
| 39 | $this->loop = $loop; |
|
| 40 | $this->signalNo = $signalNo; |
|
| 41 | $this->callback = $callback; |
|
| 42 | $this->priority = $priority; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @return EventLoop |
|
| 47 | */ |
|
| 48 | public function getLoop() |
|
| 49 | { |
|
| 50 | return $this->loop; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return int |
|
| 55 | */ |
|
| 56 | public function getSignalNo() |
|
| 57 | { |
|
| 58 | return $this->signalNo; |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @return callable |
|
| 63 | */ |
|
| 64 | public function getCallback() |
|
| 65 | { |
|
| 66 | return $this->callback; |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @return int |
|
| 71 | */ |
|
| 72 | public function getPriority() |
|
| 73 | { |
|
| 74 | return $this->priority; |
|
| 75 | } |
|
| 76 | ||
| 77 | public function cancel() |
|
| 78 | { |
|
| 79 | $this->loop->cancelSignal($this); |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||