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