@@ -193,14 +193,49 @@ public function isTimerActive(TimerInterface $timer);
193
193
* This works very much similar to timers with an interval of zero seconds,
194
194
* but does not require the overhead of scheduling a timer queue.
195
195
*
196
- * Unlike timers, callbacks are guaranteed to be executed in the order they
197
- * are enqueued.
196
+ * The tick callback function MUST be able to accept zero parameters.
197
+ *
198
+ * The tick callback function MUST NOT throw an `Exception`.
199
+ * The return value of the tick callback function will be ignored and has
200
+ * no effect, so for performance reasons you're recommended to not return
201
+ * any excessive data structures.
202
+ *
203
+ * If you want to access any variables within your callback function, you
204
+ * can bind arbitrary data to a callback closure like this:
205
+ *
206
+ * ```php
207
+ * function hello(LoopInterface $loop, $name)
208
+ * {
209
+ * $loop->futureTick(function () use ($name) {
210
+ * echo "hello $name\n";
211
+ * });
212
+ * }
213
+ *
214
+ * hello('Tester');
215
+ * ```
216
+ *
217
+ * Unlike timers, tick callbacks are guaranteed to be executed in the order
218
+ * they are enqueued.
198
219
* Also, once a callback is enqueued, there's no way to cancel this operation.
199
220
*
200
- * This is often used to break down bigger tasks into smaller steps (a form of
201
- * cooperative multitasking).
221
+ * This is often used to break down bigger tasks into smaller steps (a form
222
+ * of cooperative multitasking).
223
+ *
224
+ * ```php
225
+ * $loop->futureTick(function () {
226
+ * echo 'b';
227
+ * });
228
+ * $loop->futureTick(function () {
229
+ * echo 'c';
230
+ * });
231
+ * echo 'a';
232
+ * ```
233
+ *
234
+ * See also [example #3](examples).
202
235
*
203
236
* @param callable $listener The callback to invoke.
237
+ *
238
+ * @return void
204
239
*/
205
240
public function futureTick (callable $ listener );
206
241
0 commit comments