Skip to content

Commit d89d169

Browse files
committed
Add further specification for loop drivers
1 parent 8feb808 commit d89d169

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/Loop.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public static function cancel($watcherId)
233233
/**
234234
* Reference a watcher.
235235
*
236-
* This will keep the event loop alive whilst the event is still being monitored. Watchers have this state by
236+
* This will keep the event loop alive whilst the watcher is still being monitored. Watchers have this state by
237237
* default.
238238
*
239239
* @param string $watcherId The watcher identifier.
@@ -248,8 +248,8 @@ public static function reference($watcherId)
248248
/**
249249
* Unreference a watcher.
250250
*
251-
* The event loop should exit the run method when only unreferenced watchers are still being monitored. Events are
252-
* all referenced by default.
251+
* The event loop should exit the run method when only unreferenced watchers are still being monitored. Watchers
252+
* are all referenced by default.
253253
*
254254
* @param string $watcherId The watcher identifier.
255255
*

src/LoopDriver.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,29 @@ interface LoopDriver
77
/**
88
* Start the event loop.
99
*
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+
*
1014
* @return void
1115
*/
1216
public function run();
1317

1418
/**
1519
* Stop the event loop.
1620
*
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+
*
1724
* @return void
1825
*/
1926
public function stop();
2027

2128
/**
2229
* Defer the execution of a callback.
2330
*
31+
* The deferred callable MUST be executed in the next tick of the event loop.
32+
*
2433
* @param callable(string $watcherId, mixed $data) $callback The callback to defer.
2534
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
2635
*
@@ -29,7 +38,9 @@ public function stop();
2938
public function defer(callable $callback, $data = null);
3039

3140
/**
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.
3344
*
3445
* @param int $delay The amount of time, in milliseconds, to delay the execution for.
3546
* @param callable(string $watcherId, mixed $data) $callback The callback to delay.
@@ -40,7 +51,9 @@ public function defer(callable $callback, $data = null);
4051
public function delay($delay, callable $callback, $data = null);
4152

4253
/**
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.
4457
*
4558
* @param int $interval The time interval, in milliseconds, to wait between executions.
4659
* @param callable(string $watcherId, mixed $data) $callback The callback to repeat.
@@ -113,7 +126,8 @@ public function cancel($watcherId);
113126
/**
114127
* Reference a watcher.
115128
*
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.
117131
*
118132
* @param string $watcherId The watcher identifier.
119133
*
@@ -124,8 +138,8 @@ public function reference($watcherId);
124138
/**
125139
* Unreference a watcher.
126140
*
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.
129143
*
130144
* @param string $watcherId The watcher identifier.
131145
*

0 commit comments

Comments
 (0)