1
1
<?php
2
2
3
- namespace Voryx \React \EventLoop ;
3
+ namespace Voryx \React \AsyncInterop ;
4
4
5
- use Interop \Async \Loop ;
5
+ use Interop \Async \Loop as InteropLoop ;
6
6
use React \EventLoop \LoopInterface ;
7
7
use React \EventLoop \Timer \TimerInterface ;
8
8
9
- class ReactAsyncInteropLoop implements LoopInterface
9
+ final class Loop implements LoopInterface
10
10
{
11
11
private $ readStreams = [];
12
12
private $ writeStreams = [];
@@ -17,7 +17,7 @@ public function addReadStream($stream, callable $listener)
17
17
if (isset ($ this ->readStreams [$ key ])) {
18
18
throw new \Exception ('key set twice ' );
19
19
}
20
- $ this ->readStreams [$ key ] = Loop ::get ()->onReadable ($ stream , function () use ($ listener , $ stream ) {
20
+ $ this ->readStreams [$ key ] = InteropLoop ::get ()->onReadable ($ stream , function () use ($ listener , $ stream ) {
21
21
$ listener ($ stream );
22
22
});
23
23
}
@@ -30,7 +30,7 @@ public function addWriteStream($stream, callable $listener)
30
30
throw new \Exception ('key set twice ' );
31
31
}
32
32
33
- $ this ->writeStreams [$ key ] = Loop ::get ()->onWritable ($ stream , function () use ($ listener , $ stream ) {
33
+ $ this ->writeStreams [$ key ] = InteropLoop ::get ()->onWritable ($ stream , function () use ($ listener , $ stream ) {
34
34
$ listener ($ stream );
35
35
});
36
36
}
@@ -39,7 +39,7 @@ public function removeReadStream($stream)
39
39
{
40
40
$ key = (int )$ stream ;
41
41
if (isset ($ this ->readStreams [$ key ])) {
42
- Loop ::get ()->cancel ($ this ->readStreams [$ key ]);
42
+ InteropLoop ::get ()->cancel ($ this ->readStreams [$ key ]);
43
43
unset($ this ->readStreams [$ key ]);
44
44
}
45
45
}
@@ -48,7 +48,7 @@ public function removeWriteStream($stream)
48
48
{
49
49
$ key = (int )$ stream ;
50
50
if (isset ($ this ->writeStreams [$ key ])) {
51
- Loop ::get ()->cancel ($ this ->writeStreams [$ key ]);
51
+ InteropLoop ::get ()->cancel ($ this ->writeStreams [$ key ]);
52
52
unset($ this ->writeStreams [$ key ]);
53
53
}
54
54
}
@@ -66,11 +66,11 @@ private function addWrappedTimer($interval, callable $callback, $isPeriodic = fa
66
66
};
67
67
$ millis = $ interval * 1000 ;
68
68
if ($ isPeriodic ) {
69
- $ timerKey = Loop ::get ()->repeat ($ millis , $ wrappedCallback );
69
+ $ timerKey = InteropLoop ::get ()->repeat ($ millis , $ wrappedCallback );
70
70
} else {
71
- $ timerKey = Loop ::get ()->delay ($ millis , $ wrappedCallback );
71
+ $ timerKey = InteropLoop ::get ()->delay ($ millis , $ wrappedCallback );
72
72
}
73
- $ timer = new ReactAsyncInteropTimer (
73
+ $ timer = new Timer (
74
74
$ timerKey ,
75
75
$ interval ,
76
76
$ callback ,
@@ -102,7 +102,7 @@ public function isTimerActive(TimerInterface $timer)
102
102
103
103
public function nextTick (callable $ listener )
104
104
{
105
- Loop ::get ()->defer (function () use ($ listener ) {
105
+ InteropLoop ::get ()->defer (function () use ($ listener ) {
106
106
$ listener ($ this );
107
107
});
108
108
}
@@ -114,7 +114,7 @@ public function futureTick(callable $listener)
114
114
115
115
public function tick ()
116
116
{
117
- $ loop = Loop ::get ();
117
+ $ loop = InteropLoop ::get ();
118
118
119
119
$ loop ->defer (function () use ($ loop ) {
120
120
$ loop ->stop ();
@@ -125,11 +125,11 @@ public function tick()
125
125
126
126
public function run ()
127
127
{
128
- Loop ::get ()->run ();
128
+ InteropLoop ::get ()->run ();
129
129
}
130
130
131
131
public function stop ()
132
132
{
133
- Loop ::get ()->stop ();
133
+ InteropLoop ::get ()->stop ();
134
134
}
135
135
}
0 commit comments