… | |
… | |
37 | # readonly available (at least 5.8.9+, working better in 5.10.1+) |
37 | # readonly available (at least 5.8.9+, working better in 5.10.1+) |
38 | *wrap = sub { |
38 | *wrap = sub { |
39 | my $cb = shift; |
39 | my $cb = shift; |
40 | |
40 | |
41 | sub { |
41 | sub { |
|
|
42 | local $_; |
42 | Internals::SvREADONLY $_, 1; |
43 | Internals::SvREADONLY $_, 1; |
43 | &$cb; |
44 | &$cb; |
44 | Internals::SvREADONLY $_, 0; |
|
|
45 | } |
45 | } |
46 | }; |
46 | }; |
47 | } else { |
47 | } else { |
48 | # or not :/ |
48 | # or not :/ |
49 | my $magic = []; # a unique magic value |
49 | my $magic = []; # a unique magic value |
… | |
… | |
69 | our $FD_CHECK_W = AE::timer 4, 4, sub { |
69 | our $FD_CHECK_W = AE::timer 4, 4, sub { |
70 | my $cnt = (@FD_INUSE < 100 * 10 ? int @FD_INUSE * 0.1 : 100) || 10; |
70 | my $cnt = (@FD_INUSE < 100 * 10 ? int @FD_INUSE * 0.1 : 100) || 10; |
71 | |
71 | |
72 | if ($FD_I <= 0) { |
72 | if ($FD_I <= 0) { |
73 | #pop @FD_INUSE while @FD_INUSE && !$FD_INUSE[-1]; |
73 | #pop @FD_INUSE while @FD_INUSE && !$FD_INUSE[-1]; |
74 | ($FD_I = @FD_INUSE) >= 0 |
74 | $FD_I = @FD_INUSE |
75 | or return; # empty |
75 | or return; # empty |
76 | } |
76 | } |
77 | |
77 | |
78 | $cnt = $FD_I if $cnt > $FD_I; |
78 | $cnt = $FD_I if $cnt > $FD_I; |
79 | |
79 | |
… | |
… | |
83 | or (POSIX::lseek $FD_I, 0, 1) != -1 |
83 | or (POSIX::lseek $FD_I, 0, 1) != -1 |
84 | or $! != Errno::EBADF |
84 | or $! != Errno::EBADF |
85 | or die; |
85 | or die; |
86 | } while --$cnt; |
86 | } while --$cnt; |
87 | 1 |
87 | 1 |
88 | } or AE::log crit => "file descriptor $FD_I registered with AnyEvent but prematurely closed, event loop might malfunction.\n"; |
88 | } or AE::log crit => "File descriptor $FD_I registered with AnyEvent but prematurely closed, event loop might malfunction."; |
89 | }; |
89 | }; |
90 | |
90 | |
91 | sub io { |
91 | sub io { |
92 | my $class = shift; |
92 | my $class = shift; |
93 | my (%arg, $fh, $cb, $fd) = @_; |
93 | my (%arg, $fh, $cb, $fd) = @_; |
… | |
… | |
231 | and croak "AnyEvent->now wrongly called with paramaters"; |
231 | and croak "AnyEvent->now wrongly called with paramaters"; |
232 | |
232 | |
233 | $class->SUPER::now (@_) |
233 | $class->SUPER::now (@_) |
234 | } |
234 | } |
235 | |
235 | |
236 | 1; |
|
|
237 | |
|
|
238 | =head1 AUTHOR |
236 | =head1 AUTHOR |
239 | |
237 | |
240 | Marc Lehmann <schmorp@schmorp.de> |
238 | Marc Lehmann <schmorp@schmorp.de> |
241 | http://home.schmorp.de/ |
239 | http://home.schmorp.de/ |
242 | |
240 | |
243 | =cut |
241 | =cut |
244 | |
242 | |
|
|
243 | 1 |
|
|
244 | |