… | |
… | |
152 | =head2 I/O WATCHERS |
152 | =head2 I/O WATCHERS |
153 | |
153 | |
154 | You can create an I/O watcher by calling the C<< AnyEvent->io >> method |
154 | You can create an I/O watcher by calling the C<< AnyEvent->io >> method |
155 | with the following mandatory key-value pairs as arguments: |
155 | with the following mandatory key-value pairs as arguments: |
156 | |
156 | |
157 | C<fh> the Perl I<file handle> (I<not> file descriptor) to watch |
157 | C<fh> the Perl I<file handle> (I<not> file descriptor) to watch for events |
158 | for events. C<poll> must be a string that is either C<r> or C<w>, |
158 | (AnyEvent might or might not keep a reference to this file handle). C<poll> |
159 | which creates a watcher waiting for "r"eadable or "w"ritable events, |
159 | must be a string that is either C<r> or C<w>, which creates a watcher |
160 | respectively. C<cb> is the callback to invoke each time the file handle |
160 | waiting for "r"eadable or "w"ritable events, respectively. C<cb> is the |
161 | becomes ready. |
161 | callback to invoke each time the file handle becomes ready. |
162 | |
162 | |
163 | Although the callback might get passed parameters, their value and |
163 | Although the callback might get passed parameters, their value and |
164 | presence is undefined and you cannot rely on them. Portable AnyEvent |
164 | presence is undefined and you cannot rely on them. Portable AnyEvent |
165 | callbacks cannot use arguments passed to I/O watcher callbacks. |
165 | callbacks cannot use arguments passed to I/O watcher callbacks. |
166 | |
166 | |
… | |
… | |
193 | Although the callback might get passed parameters, their value and |
193 | Although the callback might get passed parameters, their value and |
194 | presence is undefined and you cannot rely on them. Portable AnyEvent |
194 | presence is undefined and you cannot rely on them. Portable AnyEvent |
195 | callbacks cannot use arguments passed to time watcher callbacks. |
195 | callbacks cannot use arguments passed to time watcher callbacks. |
196 | |
196 | |
197 | The callback will normally be invoked once only. If you specify another |
197 | The callback will normally be invoked once only. If you specify another |
198 | parameter, C<interval>, as a positive number, then the callback will be |
198 | parameter, C<interval>, as a strictly positive number (> 0), then the |
199 | invoked regularly at that interval (in fractional seconds) after the first |
199 | callback will be invoked regularly at that interval (in fractional |
200 | invocation. |
200 | seconds) after the first invocation. If C<interval> is specified with a |
|
|
201 | false value, then it is treated as if it were missing. |
201 | |
202 | |
202 | The callback will be rescheduled before invoking the callback, but no |
203 | The callback will be rescheduled before invoking the callback, but no |
203 | attempt is done to avoid timer drift in most backends, so the interval is |
204 | attempt is done to avoid timer drift in most backends, so the interval is |
204 | only approximate. |
205 | only approximate. |
205 | |
206 | |