ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/README
(Generate patch)

Comparing AnyEvent/README (file contents):
Revision 1.35 by root, Wed Mar 25 17:33:11 2009 UTC vs.
Revision 1.36 by root, Fri Mar 27 10:49:50 2009 UTC

132 These watchers are normal Perl objects with normal Perl lifetime. After 132 These watchers are normal Perl objects with normal Perl lifetime. After
133 creating a watcher it will immediately "watch" for events and invoke the 133 creating a watcher it will immediately "watch" for events and invoke the
134 callback when the event occurs (of course, only when the event model is 134 callback when the event occurs (of course, only when the event model is
135 in control). 135 in control).
136 136
137 Note that callbacks must not permanently change global variables
138 potentially in use by the event loop (such as $_ or $[) and that
139 callbacks must not "die". The former is good programming practise in
140 Perl and the latter stems from the fact that exception handling differs
141 widely between event loops.
142
137 To disable the watcher you have to destroy it (e.g. by setting the 143 To disable the watcher you have to destroy it (e.g. by setting the
138 variable you store it in to "undef" or otherwise deleting all references 144 variable you store it in to "undef" or otherwise deleting all references
139 to it). 145 to it).
140 146
141 All watchers are created by calling a method on the "AnyEvent" class. 147 All watchers are created by calling a method on the "AnyEvent" class.
156 162
157 I/O WATCHERS 163 I/O WATCHERS
158 You can create an I/O watcher by calling the "AnyEvent->io" method with 164 You can create an I/O watcher by calling the "AnyEvent->io" method with
159 the following mandatory key-value pairs as arguments: 165 the following mandatory key-value pairs as arguments:
160 166
161 "fh" the Perl *file handle* (*not* file descriptor) to watch for events 167 "fh" is the Perl *file handle* (*not* file descriptor) to watch for
162 (AnyEvent might or might not keep a reference to this file handle). 168 events (AnyEvent might or might not keep a reference to this file
169 handle). Note that only file handles pointing to things for which
170 non-blocking operation makes sense are allowed. This includes sockets,
171 most character devices, pipes, fifos and so on, but not for example
172 files or block devices.
173
163 "poll" must be a string that is either "r" or "w", which creates a 174 "poll" must be a string that is either "r" or "w", which creates a
164 watcher waiting for "r"eadable or "w"ritable events, respectively. "cb" 175 watcher waiting for "r"eadable or "w"ritable events, respectively.
176
165 is the callback to invoke each time the file handle becomes ready. 177 "cb" is the callback to invoke each time the file handle becomes ready.
166 178
167 Although the callback might get passed parameters, their value and 179 Although the callback might get passed parameters, their value and
168 presence is undefined and you cannot rely on them. Portable AnyEvent 180 presence is undefined and you cannot rely on them. Portable AnyEvent
169 callbacks cannot use arguments passed to I/O watcher callbacks. 181 callbacks cannot use arguments passed to I/O watcher callbacks.
170 182
1387 1399
1388BUGS 1400BUGS
1389 Perl 5.8 has numerous memleaks that sometimes hit this module and are 1401 Perl 5.8 has numerous memleaks that sometimes hit this module and are
1390 hard to work around. If you suffer from memleaks, first upgrade to Perl 1402 hard to work around. If you suffer from memleaks, first upgrade to Perl
1391 5.10 and check wether the leaks still show up. (Perl 5.10.0 has other 1403 5.10 and check wether the leaks still show up. (Perl 5.10.0 has other
1392 annoying mamleaks, such as leaking on "map" and "grep" but it is usually 1404 annoying memleaks, such as leaking on "map" and "grep" but it is usually
1393 not as pronounced). 1405 not as pronounced).
1394 1406
1395SEE ALSO 1407SEE ALSO
1396 Utility functions: AnyEvent::Util. 1408 Utility functions: AnyEvent::Util.
1397 1409

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines