… | |
… | |
558 | $self->oobinline (exists $self->{oobinline} ? delete $self->{oobinline} : 1); |
558 | $self->oobinline (exists $self->{oobinline} ? delete $self->{oobinline} : 1); |
559 | |
559 | |
560 | $self->starttls (delete $self->{tls}, delete $self->{tls_ctx}) |
560 | $self->starttls (delete $self->{tls}, delete $self->{tls_ctx}) |
561 | if $self->{tls}; |
561 | if $self->{tls}; |
562 | |
562 | |
563 | $self->on_drain (delete $self->{on_drain}) if $self->{on_drain}; |
563 | $self->on_drain (delete $self->{on_drain} ) if $self->{on_drain}; |
564 | |
564 | |
565 | $self->start_read |
565 | $self->start_read |
566 | if $self->{on_read} || @{ $self->{_queue} }; |
566 | if $self->{on_read} || @{ $self->{_queue} }; |
567 | |
567 | |
568 | $self->_drain_wbuf; |
568 | $self->_drain_wbuf; |
… | |
… | |
1271 | $self->_drain_rbuf if $cb; |
1271 | $self->_drain_rbuf if $cb; |
1272 | } |
1272 | } |
1273 | |
1273 | |
1274 | =item $handle->rbuf |
1274 | =item $handle->rbuf |
1275 | |
1275 | |
1276 | Returns the read buffer (as a modifiable lvalue). |
1276 | Returns the read buffer (as a modifiable lvalue). You can also access the |
|
|
1277 | read buffer directly as the C<< ->{rbuf} >> member, if you want (this is |
|
|
1278 | much faster, and no less clean). |
1277 | |
1279 | |
1278 | You can access the read buffer directly as the C<< ->{rbuf} >> |
1280 | The only operation allowed on the read buffer (apart from looking at it) |
1279 | member, if you want. However, the only operation allowed on the |
1281 | is removing data from its beginning. Otherwise modifying or appending to |
1280 | read buffer (apart from looking at it) is removing data from its |
1282 | it is not allowed and will lead to hard-to-track-down bugs. |
1281 | beginning. Otherwise modifying or appending to it is not allowed and will |
|
|
1282 | lead to hard-to-track-down bugs. |
|
|
1283 | |
1283 | |
1284 | NOTE: The read buffer should only be used or modified if the C<on_read>, |
1284 | NOTE: The read buffer should only be used or modified in the C<on_read> |
1285 | C<push_read> or C<unshift_read> methods are used. The other read methods |
1285 | callback or when C<push_read> or C<unshift_read> are used with a single |
1286 | automatically manage the read buffer. |
1286 | callback (i.e. untyped). Typed C<push_read> and C<unshift_read> methods |
|
|
1287 | will manage the read buffer on their own. |
1287 | |
1288 | |
1288 | =cut |
1289 | =cut |
1289 | |
1290 | |
1290 | sub rbuf : lvalue { |
1291 | sub rbuf : lvalue { |
1291 | $_[0]{rbuf} |
1292 | $_[0]{rbuf} |
… | |
… | |
1342 | my $cb = pop; |
1343 | my $cb = pop; |
1343 | |
1344 | |
1344 | if (@_) { |
1345 | if (@_) { |
1345 | my $type = shift; |
1346 | my $type = shift; |
1346 | |
1347 | |
|
|
1348 | $cb = ($RH{$type} ||= _load_func "$type\::anyevent_read_type" |
1347 | $cb = ($RH{$type} or Carp::croak "unsupported type passed to AnyEvent::Handle::unshift_read") |
1349 | or Carp::croak "unsupported/unloadable type '$type' passed to AnyEvent::Handle::unshift_read") |
1348 | ->($self, $cb, @_); |
1350 | ->($self, $cb, @_); |
1349 | } |
1351 | } |
1350 | |
1352 | |
1351 | unshift @{ $self->{_queue} }, $cb; |
1353 | unshift @{ $self->{_queue} }, $cb; |
1352 | $self->_drain_rbuf; |
1354 | $self->_drain_rbuf; |