@@ -91,14 +91,49 @@ public function isTimerActive(TimerInterface $timer);
91
91
* This works very much similar to timers with an interval of zero seconds,
92
92
* but does not require the overhead of scheduling a timer queue.
93
93
*
94
- * Unlike timers, callbacks are guaranteed to be executed in the order they
95
- * are enqueued.
94
+ * The tick callback function MUST be able to accept zero parameters.
95
+ *
96
+ * The tick callback function MUST NOT throw an `Exception`.
97
+ * The return value of the tick callback function will be ignored and has
98
+ * no effect, so for performance reasons you're recommended to not return
99
+ * any excessive data structures.
100
+ *
101
+ * If you want to access any variables within your callback function, you
102
+ * can bind arbitrary data to a callback closure like this:
103
+ *
104
+ * ```php
105
+ * function hello(LoopInterface $loop, $name)
106
+ * {
107
+ * $loop->futureTick(function () use ($name) {
108
+ * echo "hello $name\n";
109
+ * });
110
+ * }
111
+ *
112
+ * hello('Tester');
113
+ * ```
114
+ *
115
+ * Unlike timers, tick callbacks are guaranteed to be executed in the order
116
+ * they are enqueued.
96
117
* Also, once a callback is enqueued, there's no way to cancel this operation.
97
118
*
98
- * This is often used to break down bigger tasks into smaller steps (a form of
99
- * cooperative multitasking).
119
+ * This is often used to break down bigger tasks into smaller steps (a form
120
+ * of cooperative multitasking).
121
+ *
122
+ * ```php
123
+ * $loop->futureTick(function () {
124
+ * echo 'b';
125
+ * });
126
+ * $loop->futureTick(function () {
127
+ * echo 'c';
128
+ * });
129
+ * echo 'a';
130
+ * ```
131
+ *
132
+ * See also [example #3](examples).
100
133
*
101
134
* @param callable $listener The callback to invoke.
135
+ *
136
+ * @return void
102
137
*/
103
138
public function futureTick (callable $ listener );
104
139
0 commit comments