@@ -24,17 +24,17 @@ protected function createLibeventCallback()
24
24
$ writeCbks = &$ this ->writeCallbacks ;
25
25
26
26
return function ($ stream , $ flags , $ loop ) use (&$ readCbks , &$ writeCbks ) {
27
- $ streamID = (int ) $ stream ;
27
+ $ id = (int ) $ stream ;
28
28
29
29
try {
30
- if (($ flags & EV_READ ) === EV_READ && isset ($ readCbks [$ streamID ])) {
31
- if (call_user_func ($ readCbks [$ streamID ], $ stream , $ loop ) === false ) {
30
+ if (($ flags & EV_READ ) === EV_READ && isset ($ readCbks [$ id ])) {
31
+ if (call_user_func ($ readCbks [$ id ], $ stream , $ loop ) === false ) {
32
32
$ loop ->removeReadStream ($ stream );
33
33
}
34
34
}
35
35
36
- if (($ flags & EV_WRITE ) === EV_WRITE && isset ($ writeCbks [$ streamID ])) {
37
- if (call_user_func ($ writeCbks [$ streamID ], $ stream , $ loop ) === false ) {
36
+ if (($ flags & EV_WRITE ) === EV_WRITE && isset ($ writeCbks [$ id ])) {
37
+ if (call_user_func ($ writeCbks [$ id ], $ stream , $ loop ) === false ) {
38
38
$ loop ->removeWriteStream ($ stream );
39
39
}
40
40
}
@@ -60,19 +60,19 @@ public function addWriteStream($stream, $listener)
60
60
61
61
protected function addStreamEvent ($ stream , $ eventClass , $ eventCallbacks , $ listener )
62
62
{
63
- $ streamID = (int ) $ stream ;
63
+ $ id = (int ) $ stream ;
64
64
65
- if ($ existing = isset ($ this ->events [$ streamID ])) {
66
- if (($ this ->flags [$ streamID ] & $ eventClass ) === $ eventClass ) {
65
+ if ($ existing = isset ($ this ->events [$ id ])) {
66
+ if (($ this ->flags [$ id ] & $ eventClass ) === $ eventClass ) {
67
67
return ;
68
68
}
69
- $ event = $ this ->events [$ streamID ];
69
+ $ event = $ this ->events [$ id ];
70
70
event_del ($ event );
71
71
} else {
72
72
$ event = event_new ();
73
73
}
74
74
75
- $ flags = isset ($ this ->flags [$ streamID ]) ? $ this ->flags [$ streamID ] | $ eventClass : $ eventClass ;
75
+ $ flags = isset ($ this ->flags [$ id ]) ? $ this ->flags [$ id ] | $ eventClass : $ eventClass ;
76
76
event_set ($ event , $ stream , $ flags | EV_PERSIST , $ this ->callback , $ this );
77
77
78
78
if (!$ existing ) {
@@ -82,9 +82,9 @@ protected function addStreamEvent($stream, $eventClass, $eventCallbacks, $listen
82
82
83
83
event_add ($ event );
84
84
85
- $ this ->events [$ streamID ] = $ event ;
86
- $ this ->flags [$ streamID ] = $ flags ;
87
- $ this ->{"{$ eventCallbacks }Callbacks " }[$ streamID ] = $ listener ;
85
+ $ this ->events [$ id ] = $ event ;
86
+ $ this ->flags [$ id ] = $ flags ;
87
+ $ this ->{"{$ eventCallbacks }Callbacks " }[$ id ] = $ listener ;
88
88
}
89
89
90
90
public function removeReadStream ($ stream )
@@ -99,42 +99,42 @@ public function removeWriteStream($stream)
99
99
100
100
protected function removeStreamEvent ($ stream , $ eventClass , $ eventCallbacks )
101
101
{
102
- $ streamID = (int ) $ stream ;
102
+ $ id = (int ) $ stream ;
103
103
104
- if (isset ($ this ->events [$ streamID ])) {
105
- $ flags = $ this ->flags [$ streamID ] & ~$ eventClass ;
104
+ if (isset ($ this ->events [$ id ])) {
105
+ $ flags = $ this ->flags [$ id ] & ~$ eventClass ;
106
106
107
107
if ($ flags === 0 ) {
108
108
// Remove if stream is not subscribed to any event at this point.
109
109
return $ this ->removeStream ($ stream );
110
110
}
111
111
112
- $ event = $ this ->events [$ streamID ];
112
+ $ event = $ this ->events [$ id ];
113
113
114
114
event_del ($ event );
115
115
event_set ($ event , $ stream , $ flags | EV_PERSIST , $ this ->callback , $ this );
116
116
event_add ($ event );
117
117
118
- $ this ->flags [$ streamID ] = $ flags ;
119
- unset($ this ->{"{$ eventCallbacks }Callbacks " }[$ streamID ]);
118
+ $ this ->flags [$ id ] = $ flags ;
119
+ unset($ this ->{"{$ eventCallbacks }Callbacks " }[$ id ]);
120
120
}
121
121
}
122
122
123
123
public function removeStream ($ stream )
124
124
{
125
- $ streamID = (int ) $ stream ;
125
+ $ id = (int ) $ stream ;
126
126
127
- if (isset ($ this ->events [$ streamID ])) {
128
- $ event = $ this ->events [$ streamID ];
127
+ if (isset ($ this ->events [$ id ])) {
128
+ $ event = $ this ->events [$ id ];
129
129
130
130
event_del ($ event );
131
131
event_free ($ event );
132
132
133
133
unset(
134
- $ this ->events [$ streamID ],
135
- $ this ->flags [$ streamID ],
136
- $ this ->readCallbacks [$ streamID ],
137
- $ this ->writeCallbacks [$ streamID ]
134
+ $ this ->events [$ id ],
135
+ $ this ->flags [$ id ],
136
+ $ this ->readCallbacks [$ id ],
137
+ $ this ->writeCallbacks [$ id ]
138
138
);
139
139
}
140
140
}
0 commit comments