Permalink
Browse files

non-AE::Handles can push_read to a real AE::Handle. SIGH.

  • Loading branch information...
jrockway committed Apr 16, 2010
1 parent 715c59e commit fba28a7de8504e4f0d954d0711742e6b47f31249
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/AnyEvent/Pump.pm
View
@@ -11,12 +11,15 @@ use Sub::Exporter -setup => {
sub pump($$;&){
my ($from, $to, $filter) = @_;
- my $from_is_ah = $from->isa('AnyEvent::Handle');
$filter ||= sub { $_[0] }; # identity function
my $pusher; $pusher = sub {
my $_from = shift;
- my $data = $from_is_ah ? delete $_from->{rbuf} : $_from->consume;
+
+ my $data = $_from->isa('AnyEvent::Handle')
+ ? delete $_from->{rbuf}
+ : $_from->consume;
+
return 0 unless defined $data;
my $filtered = $filter->($data);
@@ -29,7 +32,7 @@ sub pump($$;&){
$from->push_read($pusher);
return guard {
- if($from_is_ah){
+ if($from->isa('AnyEvent::Handle')){
$from->{_queue} = [
grep { refaddr $_ != refaddr $pusher } @{$from->{_queue} || []}
];

0 comments on commit fba28a7

Please sign in to comment.