… | |
… | |
43 | $cv->wait; |
43 | $cv->wait; |
44 | |
44 | |
45 | =head1 DESCRIPTION |
45 | =head1 DESCRIPTION |
46 | |
46 | |
47 | This module is a helper module to make it easier to do event-based I/O on |
47 | This module is a helper module to make it easier to do event-based I/O on |
48 | filehandles (and sockets, see L<AnyEvent::Socket> for an easy way to make |
48 | filehandles. For utility functions for doing non-blocking connects and accepts |
49 | non-blocking resolves and connects). |
49 | on sockets see L<AnyEvent::Util>. |
50 | |
50 | |
51 | In the following, when the documentation refers to of "bytes" then this |
51 | In the following, when the documentation refers to of "bytes" then this |
52 | means characters. As sysread and syswrite are used for all I/O, their |
52 | means characters. As sysread and syswrite are used for all I/O, their |
53 | treatment of characters applies to this module as well. |
53 | treatment of characters applies to this module as well. |
54 | |
54 | |
… | |
… | |
485 | sub _read_chunk($$) { |
485 | sub _read_chunk($$) { |
486 | my ($self, $len, $cb) = @_; |
486 | my ($self, $len, $cb) = @_; |
487 | |
487 | |
488 | sub { |
488 | sub { |
489 | $len <= length $_[0]{rbuf} or return; |
489 | $len <= length $_[0]{rbuf} or return; |
490 | $cb->($self, $_[0], substr $_[0]{rbuf}, 0, $len, ""); |
490 | $cb->($_[0], substr $_[0]{rbuf}, 0, $len, ""); |
491 | 1 |
491 | 1 |
492 | } |
492 | } |
493 | } |
493 | } |
494 | |
494 | |
495 | sub push_read_chunk { |
495 | sub push_read_chunk { |
… | |
… | |
537 | $eol = qr|^(.*?)($eol)|; |
537 | $eol = qr|^(.*?)($eol)|; |
538 | |
538 | |
539 | sub { |
539 | sub { |
540 | $_[0]{rbuf} =~ s/$eol// or return; |
540 | $_[0]{rbuf} =~ s/$eol// or return; |
541 | |
541 | |
542 | $cb->($self, $1, $2); |
542 | $cb->($_[0], $1, $2); |
543 | 1 |
543 | 1 |
544 | } |
544 | } |
545 | } |
545 | } |
546 | |
546 | |
547 | sub push_read_line { |
547 | sub push_read_line { |