@@ -47,8 +47,11 @@ abstract public function stop();
47
47
/**
48
48
* Defer the execution of a callback.
49
49
*
50
- * The deferred callable MUST be executed in the next tick of the event loop and before any other type of watcher.
51
- * Order of enabling MUST be preserved when executing the callbacks.
50
+ * The deferred callable MUST be executed before any other type of watcher in a tick. Order of enabling MUST be
51
+ * preserved when executing the callbacks.
52
+ *
53
+ * The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
54
+ * right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
52
55
*
53
56
* @param callable(string $watcherId, mixed $data) $callback The callback to defer. The `$watcherId` will be
54
57
* invalidated before the callback call.
@@ -64,6 +67,9 @@ abstract public function defer(callable $callback, $data = null);
64
67
* The delay is a minimum and approximate, accuracy is not guaranteed. Order of calls MUST be determined by which
65
68
* timers expire first, but timers with the same expiration time MAY be executed in any order.
66
69
*
70
+ * The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
71
+ * right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
72
+ *
67
73
* @param int $delay The amount of time, in milliseconds, to delay the execution for.
68
74
* @param callable(string $watcherId, mixed $data) $callback The callback to delay. The `$watcherId` will be
69
75
* invalidated before the callback call.
@@ -80,6 +86,9 @@ abstract public function delay($delay, callable $callback, $data = null);
80
86
* determined by which timers expire first, but timers with the same expiration time MAY be executed in any order.
81
87
* The first execution is scheduled after the first interval period.
82
88
*
89
+ * The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
90
+ * right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
91
+ *
83
92
* @param int $interval The time interval, in milliseconds, to wait between executions.
84
93
* @param callable(string $watcherId, mixed $data) $callback The callback to repeat.
85
94
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
@@ -98,6 +107,9 @@ abstract public function repeat($interval, callable $callback, $data = null);
98
107
*
99
108
* Multiple watchers on the same stream MAY be executed in any order.
100
109
*
110
+ * The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
111
+ * right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
112
+ *
101
113
* @param resource $stream The stream to monitor.
102
114
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
103
115
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
@@ -116,6 +128,9 @@ abstract public function onReadable($stream, callable $callback, $data = null);
116
128
*
117
129
* Multiple watchers on the same stream MAY be executed in any order.
118
130
*
131
+ * The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
132
+ * right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
133
+ *
119
134
* @param resource $stream The stream to monitor.
120
135
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
121
136
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
@@ -133,6 +148,9 @@ abstract public function onWritable($stream, callable $callback, $data = null);
133
148
*
134
149
* Multiple watchers on the same signal MAY be executed in any order.
135
150
*
151
+ * The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
152
+ * right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
153
+ *
136
154
* @param int $signo The signal number to monitor.
137
155
* @param callable(string $watcherId, int $signo, mixed $data) $callback The callback to execute.
138
156
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
@@ -144,7 +162,7 @@ abstract public function onWritable($stream, callable $callback, $data = null);
144
162
abstract public function onSignal ($ signo , callable $ callback , $ data = null );
145
163
146
164
/**
147
- * Enable a watcher.
165
+ * Enable a watcher to be active starting in the next tick .
148
166
*
149
167
* Watchers MUST immediately be marked as enabled, but only be activated (i.e. callbacks can be called) right before
150
168
* the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
@@ -158,7 +176,10 @@ abstract public function onSignal($signo, callable $callback, $data = null);
158
176
abstract public function enable ($ watcherId );
159
177
160
178
/**
161
- * Disable a watcher.
179
+ * Disable a watcher immediately.
180
+ *
181
+ * A watcher MUST be disabled immediately, e.g. if a defer watcher disables a later defer watcher, the second defer
182
+ * watcher isn't executed in this tick.
162
183
*
163
184
* Disabling a watcher MUST NOT invalidate the watcher. Calling this function MUST NOT fail, even if passed an
164
185
* invalid watcher.
0 commit comments