1 | <?php |
||
7 | class ReactLoop implements ReactLoopInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var LoopInterface |
||
11 | */ |
||
12 | protected $loop; |
||
13 | |||
14 | /** |
||
15 | * @param LoopInterface $loop |
||
16 | */ |
||
17 | public function __construct(LoopInterface $loop) |
||
18 | { |
||
19 | $this->loop = $loop; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * |
||
24 | */ |
||
25 | public function __destruct() |
||
26 | { |
||
27 | unset($this->loop); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @override |
||
32 | * @inheritDoc |
||
33 | */ |
||
34 | public function getActualLoop() |
||
35 | { |
||
36 | return $this->loop; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @override |
||
41 | * @inheritDoc |
||
42 | */ |
||
43 | public function addReadStream($stream, callable $listener) |
||
44 | { |
||
45 | $this->loop->addReadStream($stream, $listener); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @override |
||
50 | * @inheritDoc |
||
51 | */ |
||
52 | public function addWriteStream($stream, callable $listener) |
||
53 | { |
||
54 | $this->loop->addWriteStream($stream, $listener); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @override |
||
59 | * @inheritDoc |
||
60 | */ |
||
61 | public function removeReadStream($stream) |
||
62 | { |
||
63 | $this->loop->removeReadStream($stream); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @override |
||
68 | * @inheritDoc |
||
69 | */ |
||
70 | public function removeWriteStream($stream) |
||
71 | { |
||
72 | $this->loop->removeWriteStream($stream); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @override |
||
77 | * @inheritDoc |
||
78 | */ |
||
79 | public function removeStream($stream) |
||
80 | { |
||
81 | $this->loop->removeStream($stream); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @override |
||
86 | * @inheritDoc |
||
87 | */ |
||
88 | public function addTimer($interval, callable $callback) |
||
89 | { |
||
90 | return new ReactTimer($this->loop->addTimer($interval, $callback)); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @override |
||
95 | * @inheritDoc |
||
96 | */ |
||
97 | public function addPeriodicTimer($interval, callable $callback) |
||
98 | { |
||
99 | return new ReactTimer($this->loop->addPeriodicTimer($interval, $callback)); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @override |
||
104 | * @inheritDoc |
||
105 | */ |
||
106 | public function cancelTimer(\React\EventLoop\Timer\TimerInterface $timer) |
||
107 | { |
||
108 | $this->loop->cancelTimer($timer->getActualTimer()); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @override |
||
113 | * @inheritDoc |
||
114 | */ |
||
115 | public function isTimerActive(\React\EventLoop\Timer\TimerInterface $timer) |
||
116 | { |
||
117 | return $this->loop->isTimerActive($timer->getActualTimer()); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * @override |
||
122 | * @inheritDoc |
||
123 | */ |
||
124 | public function nextTick(callable $listener) |
||
125 | { |
||
126 | $this->loop->onBeforeTick($listener); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @override |
||
131 | * @inheritDoc |
||
132 | */ |
||
133 | public function futureTick(callable $listener) |
||
134 | { |
||
135 | $this->loop->onAfterTick($listener); |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * @override |
||
140 | * @inheritDoc |
||
141 | */ |
||
142 | public function tick() |
||
144 | |||
145 | /** |
||
146 | * @override |
||
147 | * @inheritDoc |
||
148 | */ |
||
149 | public function run() |
||
151 | |||
152 | /** |
||
153 | * @override |
||
154 | * @inheritDoc |
||
155 | */ |
||
156 | public function stop() |
||
158 | } |
||
159 |