Skip to content

Commit 9916529

Browse files
committed
'may' → 'MAY', copy docs for defer, delay, repeat from Driver to Loop
1 parent 5d9de0c commit 9916529

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

src/Loop.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,14 @@ public static function stop()
129129
/**
130130
* Defer the execution of a callback.
131131
*
132-
* @param callable(string $watcherId, mixed $data) $callback The callback to defer.
132+
* The deferred callable MUST be executed in the next tick of the event loop and before any other type of watcher.
133+
* Order of enabling MUST be preserved when executing the callbacks.
134+
*
135+
* @param callable(string $watcherId, mixed $data) $callback The callback to defer. The `$watcherId` will be
136+
* invalidated before the callback call.
133137
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
134138
*
135-
* @return string An identifier that can be used to cancel, enable or disable the watcher.
139+
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
136140
*/
137141
public static function defer(callable $callback, $data = null)
138142
{
@@ -143,13 +147,15 @@ public static function defer(callable $callback, $data = null)
143147
/**
144148
* Delay the execution of a callback.
145149
*
146-
* The delay is a minimum and approximate, accuracy is not guaranteed.
150+
* The delay is a minimum and approximate, accuracy is not guaranteed. Order of calls MUST be determined by which
151+
* timers expire first, but timers with the same expiration time MAY be executed in any order.
147152
*
148-
* @param int $time The amount of time, in milliseconds, to delay the execution for.
149-
* @param callable(string $watcherId, mixed $data) $callback The callback to delay.
153+
* @param int $delay The amount of time, in milliseconds, to delay the execution for.
154+
* @param callable(string $watcherId, mixed $data) $callback The callback to delay. The `$watcherId` will be
155+
* invalidated before the callback call.
150156
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
151157
*
152-
* @return string An identifier that can be used to cancel, enable or disable the watcher.
158+
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
153159
*/
154160
public static function delay($time, callable $callback, $data = null)
155161
{
@@ -160,14 +166,15 @@ public static function delay($time, callable $callback, $data = null)
160166
/**
161167
* Repeatedly execute a callback.
162168
*
163-
* The interval between executions is a minimum and approximate, accuracy is not guaranteed.
169+
* The interval between executions is a minimum and approximate, accuracy is not guaranteed. Order of calls MUST be
170+
* determined by which timers expire first, but timers with the same expiration time MAY be executed in any order.
164171
* The first execution is scheduled after the first interval period.
165172
*
166173
* @param int $interval The time interval, in milliseconds, to wait between executions.
167174
* @param callable(string $watcherId, mixed $data) $callback The callback to repeat.
168175
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
169176
*
170-
* @return string An identifier that can be used to cancel, enable or disable the watcher.
177+
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
171178
*/
172179
public static function repeat($interval, callable $callback, $data = null)
173180
{
@@ -179,11 +186,11 @@ public static function repeat($interval, callable $callback, $data = null)
179186
* Execute a callback when a stream resource becomes readable or is closed for reading.
180187
*
181188
* Warning: Closing resources locally, e.g. with `fclose`, might not invoke the callback. Be sure to `cancel` the
182-
* watcher when closing the resource locally. Drivers may choose to notify the user if there are watchers on invalid
189+
* watcher when closing the resource locally. Drivers MAY choose to notify the user if there are watchers on invalid
183190
* resources, but are not required to, due to the high performance impact. Watchers on closed resources are
184191
* therefore undefined behavior.
185192
*
186-
* Multiple watchers on the same stream may be executed in any order.
193+
* Multiple watchers on the same stream MAY be executed in any order.
187194
*
188195
* @param resource $stream The stream to monitor.
189196
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
@@ -201,11 +208,11 @@ public static function onReadable($stream, callable $callback, $data = null)
201208
* Execute a callback when a stream resource becomes writable or is closed for writing.
202209
*
203210
* Warning: Closing resources locally, e.g. with `fclose`, might not invoke the callback. Be sure to `cancel` the
204-
* watcher when closing the resource locally. Drivers may choose to notify the user if there are watchers on invalid
211+
* watcher when closing the resource locally. Drivers MAY choose to notify the user if there are watchers on invalid
205212
* resources, but are not required to, due to the high performance impact. Watchers on closed resources are
206213
* therefore undefined behavior.
207214
*
208-
* Multiple watchers on the same stream may be executed in any order.
215+
* Multiple watchers on the same stream MAY be executed in any order.
209216
*
210217
* @param resource $stream The stream to monitor.
211218
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
@@ -223,10 +230,10 @@ public static function onWritable($stream, callable $callback, $data = null)
223230
* Execute a callback when a signal is received.
224231
*
225232
* Warning: Installing the same signal on different instances of this interface is deemed undefined behavior.
226-
* Implementations may try to detect this, if possible, but are not required to. This is due to technical
233+
* Implementations MAY try to detect this, if possible, but are not required to. This is due to technical
227234
* limitations of the signals being registered globally per process.
228235
*
229-
* Multiple watchers on the same signal may be executed in any order.
236+
* Multiple watchers on the same signal MAY be executed in any order.
230237
*
231238
* @param int $signo The signal number to monitor.
232239
* @param callable(string $watcherId, int $signo, mixed $data) $callback The callback to execute.

src/Loop/Driver.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ abstract public function delay($delay, callable $callback, $data = null);
6666
* Repeatedly execute a callback.
6767
*
6868
* The interval between executions is a minimum and approximate, accuracy is not guaranteed. Order of calls MUST be
69-
* determined by which timers expire first, but timers with the same expiration time may be executed in any order.
69+
* determined by which timers expire first, but timers with the same expiration time MAY be executed in any order.
7070
* The first execution is scheduled after the first interval period.
7171
*
7272
* @param int $interval The time interval, in milliseconds, to wait between executions.
@@ -81,11 +81,11 @@ abstract public function repeat($interval, callable $callback, $data = null);
8181
* Execute a callback when a stream resource becomes readable or is closed for reading.
8282
*
8383
* Warning: Closing resources locally, e.g. with `fclose`, might not invoke the callback. Be sure to `cancel` the
84-
* watcher when closing the resource locally. Drivers may choose to notify the user if there are watchers on invalid
84+
* watcher when closing the resource locally. Drivers MAY choose to notify the user if there are watchers on invalid
8585
* resources, but are not required to, due to the high performance impact. Watchers on closed resources are
8686
* therefore undefined behavior.
8787
*
88-
* Multiple watchers on the same stream may be executed in any order.
88+
* Multiple watchers on the same stream MAY be executed in any order.
8989
*
9090
* @param resource $stream The stream to monitor.
9191
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
@@ -99,11 +99,11 @@ abstract public function onReadable($stream, callable $callback, $data = null);
9999
* Execute a callback when a stream resource becomes writable or is closed for writing.
100100
*
101101
* Warning: Closing resources locally, e.g. with `fclose`, might not invoke the callback. Be sure to `cancel` the
102-
* watcher when closing the resource locally. Drivers may choose to notify the user if there are watchers on invalid
102+
* watcher when closing the resource locally. Drivers MAY choose to notify the user if there are watchers on invalid
103103
* resources, but are not required to, due to the high performance impact. Watchers on closed resources are
104104
* therefore undefined behavior.
105105
*
106-
* Multiple watchers on the same stream may be executed in any order.
106+
* Multiple watchers on the same stream MAY be executed in any order.
107107
*
108108
* @param resource $stream The stream to monitor.
109109
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
@@ -117,10 +117,10 @@ abstract public function onWritable($stream, callable $callback, $data = null);
117117
* Execute a callback when a signal is received.
118118
*
119119
* Warning: Installing the same signal on different instances of this interface is deemed undefined behavior.
120-
* Implementations may try to detect this, if possible, but are not required to. This is due to technical
120+
* Implementations MAY try to detect this, if possible, but are not required to. This is due to technical
121121
* limitations of the signals being registered globally per process.
122122
*
123-
* Multiple watchers on the same signal may be executed in any order.
123+
* Multiple watchers on the same signal MAY be executed in any order.
124124
*
125125
* @param int $signo The signal number to monitor.
126126
* @param callable(string $watcherId, int $signo, mixed $data) $callback The callback to execute.

0 commit comments

Comments
 (0)