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

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.195 by root, Wed Mar 25 17:33:11 2009 UTC vs.
Revision 1.198 by root, Thu Mar 26 20:17:44 2009 UTC

136 136
137These watchers are normal Perl objects with normal Perl lifetime. After 137These watchers are normal Perl objects with normal Perl lifetime. After
138creating a watcher it will immediately "watch" for events and invoke the 138creating a watcher it will immediately "watch" for events and invoke the
139callback when the event occurs (of course, only when the event model 139callback when the event occurs (of course, only when the event model
140is in control). 140is in control).
141
142Note that B<callbacks must not permanently change global variables>
143potentially in use by the event loop (such as C<$_> or C<$[>) and that B<<
144callbacks must not C<die> >>. The former is good programming practise in
145Perl and the latter stems from the fact that exception handling differs
146widely between event loops.
141 147
142To disable the watcher you have to destroy it (e.g. by setting the 148To disable the watcher you have to destroy it (e.g. by setting the
143variable you store it in to C<undef> or otherwise deleting all references 149variable you store it in to C<undef> or otherwise deleting all references
144to it). 150to it).
145 151
1044# default implementation for ->signal 1050# default implementation for ->signal
1045 1051
1046our ($SIGPIPE_R, $SIGPIPE_W, %SIG_CB, %SIG_EV, $SIG_IO); 1052our ($SIGPIPE_R, $SIGPIPE_W, %SIG_CB, %SIG_EV, $SIG_IO);
1047 1053
1048sub _signal_exec { 1054sub _signal_exec {
1055 sysread $SIGPIPE_R, my $dummy, 4;
1056
1049 while (%SIG_EV) { 1057 while (%SIG_EV) {
1050 sysread $SIGPIPE_R, my $dummy, 4;
1051 for (keys %SIG_EV) { 1058 for (keys %SIG_EV) {
1052 delete $SIG_EV{$_}; 1059 delete $SIG_EV{$_};
1053 $_->() for values %{ $SIG_CB{$_} || {} }; 1060 $_->() for values %{ $SIG_CB{$_} || {} };
1054 } 1061 }
1055 } 1062 }
1854=head1 BUGS 1861=head1 BUGS
1855 1862
1856Perl 5.8 has numerous memleaks that sometimes hit this module and are hard 1863Perl 5.8 has numerous memleaks that sometimes hit this module and are hard
1857to work around. If you suffer from memleaks, first upgrade to Perl 5.10 1864to work around. If you suffer from memleaks, first upgrade to Perl 5.10
1858and check wether the leaks still show up. (Perl 5.10.0 has other annoying 1865and check wether the leaks still show up. (Perl 5.10.0 has other annoying
1859mamleaks, such as leaking on C<map> and C<grep> but it is usually not as 1866memleaks, such as leaking on C<map> and C<grep> but it is usually not as
1860pronounced). 1867pronounced).
1861 1868
1862 1869
1863=head1 SEE ALSO 1870=head1 SEE ALSO
1864 1871

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines