Skip to content

Commit

Permalink
remove poll_cb support
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Feb 13, 2010
1 parent 0c70837 commit 34d82fb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 65 deletions.
32 changes: 0 additions & 32 deletions lib/Twiggy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -544,37 +544,6 @@ sub new {
bless { handle => AnyEvent::Handle->new( fh => $socket ), exit_guard => $exit }, $class;
}

sub poll_cb {
my ( $self, $cb ) = @_;

my $handle = $self->{handle};

if ( $cb ) {
# notifies that now is a good time to ->write
$handle->on_drain(sub {
do {
if ( $self->{in_poll_cb} ) {
$self->{poll_again}++;
return;
} else {
local $self->{in_poll_cb} = 1;
$cb->($self);
}
} while ( delete $self->{poll_again} );
});

# notifies of client close
$handle->on_error(sub {
my $err = $_[2];
$handle->destroy;
$cb->(undef, $err);
});
} else {
$handle->on_drain;
$handle->on_error;
}
}

sub write { $_[0]{handle}->push_write($_[1]) }

sub close {
Expand All @@ -585,7 +554,6 @@ sub close {

my $handle = delete $self->{handle};
if ($handle) {
# kill poll_cb, but not $handle
$handle->on_drain;
$handle->on_error;

Expand Down
33 changes: 0 additions & 33 deletions t/anyevent_extensions.t
Original file line number Diff line number Diff line change
Expand Up @@ -80,39 +80,6 @@ local @Plack::Test::Suite::TEST = (
}
},
],
[
'coderef poll_cb',
sub {
my $cb = shift;
my $res = $cb->(GET "http://127.0.0.1/?name=miyagawa");
is $res->code, 200;
is $res->header('content_type'), 'text/plain';
is $res->content, 'Hello, name=miyagawa';
},
sub {
my $env = shift;

return sub {
my ( $write, $sock ) = @_;

my @queue = ( "Hello, ", $env->{QUERY_STRING} );

my $w = $write->([
200,
[ 'Content-Type' => 'text/plain' ],
]);
$w->poll_cb(sub {
my $writer = shift;

if ( @queue ) {
$writer->write(shift @queue);
} else {
$writer->close;
}
});
};
},
]
);

# prevent Lint middleware from being used
Expand Down

0 comments on commit 34d82fb

Please sign in to comment.