2
2
3
3
namespace Interop \Async \EventLoop ;
4
4
5
- final class EventLoop
5
+ final class Loop
6
6
{
7
7
/**
8
- * @var EventLoopDriver
8
+ * @var LoopDriver
9
9
*/
10
10
private static $ driver = null ;
11
11
12
12
/**
13
13
* Execute a callback within the scope of an event loop driver.
14
14
*
15
15
* @param callable $callback The callback to execute
16
- * @param EventLoopDriver $driver The event loop driver
16
+ * @param LoopDriver $driver The event loop driver
17
17
*
18
18
* @return void
19
19
*/
20
- public static function execute (callable $ callback , EventLoopDriver $ driver )
20
+ public static function execute (callable $ callback , LoopDriver $ driver )
21
21
{
22
22
$ previousDriver = self ::$ driver ;
23
23
@@ -34,8 +34,8 @@ public static function execute(callable $callback, EventLoopDriver $driver)
34
34
35
35
/**
36
36
* Retrieve the event loop driver that is in scope.
37
- *
38
- * @return EventLoopDriver
37
+ *
38
+ * @return LoopDriver
39
39
*/
40
40
public static function get ()
41
41
{
@@ -48,7 +48,7 @@ public static function get()
48
48
49
49
/**
50
50
* Stop the event loop.
51
- *
51
+ *
52
52
* @return void
53
53
*/
54
54
public static function stop ()
@@ -58,9 +58,9 @@ public static function stop()
58
58
59
59
/**
60
60
* Defer the execution of a callback.
61
- *
61
+ *
62
62
* @param callable $callback The callback to defer.
63
- *
63
+ *
64
64
* @return string An identifier that can be used to cancel, enable or disable the event.
65
65
*/
66
66
public static function defer (callable $ callback )
@@ -70,10 +70,10 @@ public static function defer(callable $callback)
70
70
71
71
/**
72
72
* Delay the execution of a callback. The time delay is approximate and accuracy is not guaranteed.
73
- *
73
+ *
74
74
* @param callable $callback The callback to delay.
75
75
* @param int $time The amount of time, in milliseconds, to delay the execution for.
76
- *
76
+ *
77
77
* @return string An identifier that can be used to cancel, enable or disable the event.
78
78
*/
79
79
public static function delay (callable $ callback , $ time )
@@ -83,10 +83,10 @@ public static function delay(callable $callback, $time)
83
83
84
84
/**
85
85
* Repeatedly execute a callback. The interval between executions is approximate and accuracy is not guaranteed.
86
- *
86
+ *
87
87
* @param callable $callback The callback to repeat.
88
88
* @param int $interval The time interval, in milliseconds, to wait between executions.
89
- *
89
+ *
90
90
* @return string An identifier that can be used to cancel, enable or disable the event.
91
91
*/
92
92
public static function repeat (callable $ callback , $ interval )
@@ -96,10 +96,10 @@ public static function repeat(callable $callback, $interval)
96
96
97
97
/**
98
98
* Execute a callback when a stream resource becomes readable.
99
- *
99
+ *
100
100
* @param resource $stream The stream to monitor.
101
101
* @param callable $callback The callback to execute.
102
- *
102
+ *
103
103
* @return string An identifier that can be used to cancel, enable or disable the event.
104
104
*/
105
105
public static function onReadable ($ stream , callable $ callback )
@@ -109,10 +109,10 @@ public static function onReadable($stream, callable $callback)
109
109
110
110
/**
111
111
* Execute a callback when a stream resource becomes writable.
112
- *
112
+ *
113
113
* @param resource $stream The stream to monitor.
114
114
* @param callable $callback The callback to execute.
115
- *
115
+ *
116
116
* @return string An identifier that can be used to cancel, enable or disable the event.
117
117
*/
118
118
public static function onWritable ($ stream , callable $ callback )
@@ -122,10 +122,10 @@ public static function onWritable($stream, callable $callback)
122
122
123
123
/**
124
124
* Execute a callback when a signal is received.
125
- *
125
+ *
126
126
* @param int $signo The signal number to monitor.
127
127
* @param callable $callback The callback to execute.
128
- *
128
+ *
129
129
* @return string An identifier that can be used to cancel, enable or disable the event.
130
130
*/
131
131
public static function onSignal ($ signo , callable $ callback )
@@ -135,9 +135,9 @@ public static function onSignal($signo, callable $callback)
135
135
136
136
/**
137
137
* Execute a callback when an error occurs.
138
- *
138
+ *
139
139
* @param callable $callback The callback to execute.
140
- *
140
+ *
141
141
* @return string An identifier that can be used to cancel, enable or disable the event.
142
142
*/
143
143
public static function onError (callable $ callback )
@@ -147,9 +147,9 @@ public static function onError(callable $callback)
147
147
148
148
/**
149
149
* Enable an event.
150
- *
150
+ *
151
151
* @param string $eventIdentifier The event identifier.
152
- *
152
+ *
153
153
* @return void
154
154
*/
155
155
public static function enable ($ eventIdentifier )
@@ -159,9 +159,9 @@ public static function enable($eventIdentifier)
159
159
160
160
/**
161
161
* Disable an event.
162
- *
162
+ *
163
163
* @param string $eventIdentifier The event identifier.
164
- *
164
+ *
165
165
* @return void
166
166
*/
167
167
public static function disable ($ eventIdentifier )
@@ -171,9 +171,9 @@ public static function disable($eventIdentifier)
171
171
172
172
/**
173
173
* Cancel an event.
174
- *
174
+ *
175
175
* @param string $eventIdentifier The event identifier.
176
- *
176
+ *
177
177
* @return void
178
178
*/
179
179
public static function cancel ($ eventIdentifier )
@@ -183,11 +183,11 @@ public static function cancel($eventIdentifier)
183
183
184
184
/**
185
185
* Reference an event.
186
- *
186
+ *
187
187
* This will keep the event loop alive whilst the event is still being monitored. Events have this state by default.
188
- *
188
+ *
189
189
* @param string $eventIdentifier The event identifier.
190
- *
190
+ *
191
191
* @return void
192
192
*/
193
193
public static function reference ($ eventIdentifier )
@@ -197,12 +197,12 @@ public static function reference($eventIdentifier)
197
197
198
198
/**
199
199
* Unreference an event.
200
- *
200
+ *
201
201
* The event loop should exit the run method when only unreferenced events are still being monitored. Events are all
202
202
* referenced by default.
203
- *
203
+ *
204
204
* @param string $eventIdentifier The event identifier.
205
- *
205
+ *
206
206
* @return void
207
207
*/
208
208
public static function unreference ($ eventIdentifier )
0 commit comments