AnyEvent
view release on metacpan or search on metacpan
4.231 Tue Jul 29 13:12:15 CEST 2008
- remove some debugging code left in AnyEvent::Util::fork_call
(and no, it's impossible to implement with the broken windows
perls without resource leaks or worse).
4.23 Tue Jul 29 12:19:59 CEST 2008
- document the first parameter passed to condvar callbacks to be
the callback.
- add AnyEvent::Socket::{ntoa,aton} aliases.
- optimize the AE::Handle->push_read (line) for the default
eol marker.
- optimize push_read (packstring|storable) for small packets.
- invoke on_error callback when no on_eof callback is set.
- fix a bug in push_read (storable) of unknown impact.
4.22 Sun Jul 20 16:34:13 CEST 2008
- new function AnyEvent::Socket::parse_hostport.
- as the bulkheads at microsoft can't even get getprotobyname reliably
working on their shitty fucking broken os we need to hardcode
some common protocol numbers in AnyEvent::Socket. How can
people even bother with such a pile of shit as windows.
lib/AnyEvent/Handle.pm view on Meta::CPAN
register_read_type chunk => sub {
my ($self, $cb, $len) = @_;
sub {
$len <= length $_[0]{rbuf} or return;
$cb->($_[0], substr $_[0]{rbuf}, 0, $len, "");
1
}
};
=item line => [$eol, ]$cb->($handle, $line, $eol)
The callback will be called only once a full line (including the end of
line marker, C<$eol>) has been read. This line (excluding the end of line
marker) will be passed to the callback as second argument (C<$line>), and
the end of line marker as the third argument (C<$eol>).
The end of line marker, C<$eol>, can be either a string, in which case it
will be interpreted as a fixed record end marker, or it can be a regex
object (e.g. created by C<qr>), in which case it is interpreted as a
regular expression.
The end of line marker argument C<$eol> is optional, if it is missing (NOT
undef), then C<qr|\015?\012|> is used (which is good for most internet
protocols).
Partial lines at the end of the stream will never be returned, as they are
not marked by the end of line marker.
=cut
register_read_type line => sub {
my ($self, $cb, $eol) = @_;
if (@_ < 3) {
# this is faster then the generic code below
sub {
(my $pos = index $_[0]{rbuf}, "\012") >= 0
or return;
(my $str = substr $_[0]{rbuf}, 0, $pos + 1, "") =~ s/(\015?\012)\Z// or die;
$cb->($_[0], $str, "$1");
1
}
} else {
$eol = quotemeta $eol unless ref $eol;
$eol = qr|^(.*?)($eol)|s;
sub {
$_[0]{rbuf} =~ s/$eol// or return;
$cb->($_[0], "$1", "$2");
1
}
}
};
=item regex => $accept[, $reject[, $skip], $cb->($handle, $data)
Makes a regex match against the regex object C<$accept> and returns
( run in 0.550 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )