@@ -7,20 +7,29 @@ interface LoopDriver
7
7
/**
8
8
* Start the event loop.
9
9
*
10
+ * The loop MUST continue to run until it is either stopped explicitly, no referenced watchers exist anymore, or an
11
+ * exception is thrown that cannot be handled. Exceptions that cannot be handled are exceptions thrown from an
12
+ * error handler or exceptions that would be passed to an error handler but non exists to handle them.
13
+ *
10
14
* @return void
11
15
*/
12
16
public function run ();
13
17
14
18
/**
15
19
* Stop the event loop.
16
20
*
21
+ * When an event loop is stopped, it continues with its current tick and exits the loop afterwards. Multiple calls
22
+ * to stop MUST be ignored and MUST NOT raise an exception.
23
+ *
17
24
* @return void
18
25
*/
19
26
public function stop ();
20
27
21
28
/**
22
29
* Defer the execution of a callback.
23
30
*
31
+ * The deferred callable MUST be executed in the next tick of the event loop.
32
+ *
24
33
* @param callable(string $watcherId, mixed $data) $callback The callback to defer.
25
34
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
26
35
*
@@ -29,7 +38,9 @@ public function stop();
29
38
public function defer (callable $ callback , $ data = null );
30
39
31
40
/**
32
- * Delay the execution of a callback. The time delay is approximate and accuracy is not guaranteed.
41
+ * Delay the execution of a callback.
42
+ *
43
+ * The time delay is approximate and accuracy is not guaranteed.
33
44
*
34
45
* @param int $delay The amount of time, in milliseconds, to delay the execution for.
35
46
* @param callable(string $watcherId, mixed $data) $callback The callback to delay.
@@ -40,7 +51,9 @@ public function defer(callable $callback, $data = null);
40
51
public function delay ($ delay , callable $ callback , $ data = null );
41
52
42
53
/**
43
- * Repeatedly execute a callback. The interval between executions is approximate and accuracy is not guaranteed.
54
+ * Repeatedly execute a callback.
55
+ *
56
+ * The interval between executions is approximate and accuracy is not guaranteed.
44
57
*
45
58
* @param int $interval The time interval, in milliseconds, to wait between executions.
46
59
* @param callable(string $watcherId, mixed $data) $callback The callback to repeat.
@@ -113,7 +126,8 @@ public function cancel($watcherId);
113
126
/**
114
127
* Reference a watcher.
115
128
*
116
- * This will keep the event loop alive whilst the event is still being monitored. Events have this state by default.
129
+ * This will keep the event loop alive whilst the watcher is still being monitored. Watchers have this state by
130
+ * default.
117
131
*
118
132
* @param string $watcherId The watcher identifier.
119
133
*
@@ -124,8 +138,8 @@ public function reference($watcherId);
124
138
/**
125
139
* Unreference a watcher.
126
140
*
127
- * The event loop should exit the run method when only unreferenced events are still being monitored. Events are all
128
- * referenced by default.
141
+ * The event loop should exit the run method when only unreferenced watchers are still being monitored. Watchers
142
+ * are all referenced by default.
129
143
*
130
144
* @param string $watcherId The watcher identifier.
131
145
*
0 commit comments