1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Cubiche package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) Cubiche |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Cubiche\Core\Async\Loop; |
13
|
|
|
|
14
|
|
|
use React\EventLoop\LoopInterface as BaseLoopInterface; |
15
|
|
|
use React\EventLoop\Timer\TimerInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Loop Adapter Class. |
19
|
|
|
* |
20
|
|
|
* @author Karel Osorio Ramírez <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class LoopAdapter extends Loop implements BaseLoopInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function addReadStream($stream, callable $listener) |
28
|
|
|
{ |
29
|
|
|
return $this->loop()->addReadStream($stream, $listener); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
|
|
public function addWriteStream($stream, callable $listener) |
36
|
|
|
{ |
37
|
|
|
return $this->loop()->addWriteStream($stream, $listener); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritdoc} |
42
|
|
|
*/ |
43
|
|
|
public function removeReadStream($stream) |
44
|
|
|
{ |
45
|
|
|
return $this->loop()->removeReadStream($stream); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* {@inheritdoc} |
50
|
|
|
*/ |
51
|
|
|
public function removeWriteStream($stream) |
52
|
|
|
{ |
53
|
|
|
return $this->loop()->removeWriteStream($stream); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
*/ |
59
|
|
|
public function removeStream($stream) |
60
|
|
|
{ |
61
|
|
|
return $this->loop()->removeStream($stream); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* {@inheritdoc} |
66
|
|
|
*/ |
67
|
|
|
public function addTimer($interval, callable $callback) |
68
|
|
|
{ |
69
|
|
|
return $this->loop()->addTimer($interval, $callback); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* {@inheritdoc} |
74
|
|
|
*/ |
75
|
|
|
public function addPeriodicTimer($interval, callable $callback) |
76
|
|
|
{ |
77
|
|
|
return $this->loop()->addPeriodicTimer($interval, $callback); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* {@inheritdoc} |
82
|
|
|
*/ |
83
|
|
|
public function cancelTimer(TimerInterface $timer) |
84
|
|
|
{ |
85
|
|
|
return $this->loop()->cancelTimer($timer); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* {@inheritdoc} |
90
|
|
|
*/ |
91
|
|
|
public function isTimerActive(TimerInterface $timer) |
92
|
|
|
{ |
93
|
|
|
return $this->loop()->isTimerActive($timer); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* {@inheritdoc} |
98
|
|
|
*/ |
99
|
|
|
public function nextTick(callable $listener) |
100
|
|
|
{ |
101
|
|
|
return $this->loop()->nextTick($listener); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* {@inheritdoc} |
106
|
|
|
*/ |
107
|
|
|
public function futureTick(callable $listener) |
108
|
|
|
{ |
109
|
|
|
return $this->loop()->futureTick($listener); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* {@inheritdoc} |
114
|
|
|
*/ |
115
|
|
|
public function tick() |
116
|
|
|
{ |
117
|
|
|
return $this->loop()->tick(); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* {@inheritdoc} |
122
|
|
|
*/ |
123
|
|
|
public function run() |
124
|
|
|
{ |
125
|
|
|
return $this->loop()->run(); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* {@inheritdoc} |
130
|
|
|
*/ |
131
|
|
|
public function stop() |
132
|
|
|
{ |
133
|
|
|
return $this->loop()->stop(); |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|