Acme-Sort-Sleep
view release on metacpan or search on metacpan
local/lib/perl5/IO/Async/Handle.pm view on Meta::CPAN
}
=head1 METHODS
The following methods documented with a trailing call to C<< ->get >> return
L<Future> instances.
=cut
=head2 set_handle
$handle->set_handles( %params )
Sets new reading or writing filehandles. Equivalent to calling the
C<configure> method with the same parameters.
=cut
sub set_handles
{
my $self = shift;
my %params = @_;
$self->configure(
exists $params{read_handle} ? ( read_handle => $params{read_handle} ) : (),
exists $params{write_handle} ? ( write_handle => $params{write_handle} ) : (),
);
}
=head2 set_handle
$handle->set_handle( $fh )
Shortcut for
$handle->configure( handle => $fh )
=cut
sub set_handle
{
my $self = shift;
my ( $fh ) = @_;
$self->configure( handle => $fh );
}
=head2 close
$handle->close
This method calls C<close> on the underlying IO handles. This method will then
remove the handle from its containing loop.
=cut
sub close
{
my $self = shift;
# Prevent infinite loops if there's two crosslinked handles
return if $self->{handle_closing};
$self->{handle_closing} = 1;
$self->want_readready( 0 );
$self->want_writeready( 0 );
my $read_handle = delete $self->{read_handle};
$read_handle->close if defined $read_handle;
my $write_handle = delete $self->{write_handle};
$write_handle->close if defined $write_handle;
$self->_closed;
}
sub _closed
{
my $self = shift;
$self->maybe_invoke_event( on_closed => );
if( $self->{close_futures} ) {
$_->done for @{ $self->{close_futures} };
}
$self->remove_from_parent;
}
=head2 close_read
=head2 close_write
$handle->close_read
$handle->close_write
Closes the underlying read or write handle, and deconfigures it from the
object. Neither of these methods will invoke the C<on_closed> event, nor
remove the object from the Loop if there is still one open handle in the
object. Only when both handles are closed, will C<on_closed> be fired, and the
object removed.
=cut
sub close_read
{
my $self = shift;
$self->want_readready( 0 );
my $read_handle = delete $self->{read_handle};
$read_handle->close if defined $read_handle;
$self->_closed if !$self->{write_handle};
}
sub close_write
{
my $self = shift;
$self->want_writeready( 0 );
( run in 1.440 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )