AnyEvent-AggressiveIdle

 view release on metacpan or  search on metacpan

lib/AnyEvent/AggressiveIdle.pm  view on Meta::CPAN


require Exporter;
our @ISA = qw(Exporter);

our $VERSION        = '0.04';

our @EXPORT         = qw(aggressive_idle);
our @EXPORT_OK      = qw(stop_aggressive_idle aggressive_idle);
our %EXPORT_TAGS    = ( all => [@EXPORT_OK] );

sub stop_aggressive_idle($) {
    our (%IDLE, $WATCHER);

    my ($no) = @_;

    croak "Invalid idle identifier: $no"
        unless $no and !ref($no) and exists $IDLE{$no};

    delete $IDLE{$no};
    undef $WATCHER unless %IDLE;
    return;

lib/AnyEvent/AggressiveIdle.pm  view on Meta::CPAN

            };
            $cb->($p, $guard);
        }

        unless ($done) {
            undef $WATCHER unless %IDLE;
        }
    }
}

sub aggressive_idle(&) {
    our ($WOBJ, $WOBJR, %IDLE, $WATCHER, $NO);
    ($WOBJR, $WOBJ) = portable_pipe unless defined $WOBJ;
    $NO = 0 unless defined $NO;

    $WATCHER = AE::io $WOBJ, 1, \&_watcher unless %IDLE;

    my $no = ++$NO;
    $IDLE{$no} = $_[0];

    return unless defined wantarray;



( run in 0.516 second using v1.01-cache-2.11-cpan-65fba6d93b7 )