Acme-Sort-Sleep
view release on metacpan or search on metacpan
local/lib/perl5/IO/Async/Internals/TimeQueue.pm view on Meta::CPAN
sub HEAP_cancel
{
my $self = shift;
my ( $id ) = @_;
$self->delete( $id );
}
sub HEAP__fire
{
my $self = shift;
my ( $now ) = @_;
my $count = 0;
while( defined( my $top = $self->top ) ) {
last if( $top->time > $now );
$self->extract_top;
$top->code->();
$count++;
}
return $count;
}
package # hide from CPAN
IO::Async::Internals::TimeQueue::Elem;
use strict;
our @ISA = qw( Heap::Elem );
sub new
{
my $self = shift;
my $class = ref $self || $self;
my ( $time, $code ) = @_;
my $new = $class->SUPER::new(
time => $time,
code => $code,
);
return $new;
}
sub time
{
my $self = shift;
return $self->val->{time};
}
sub code
{
my $self = shift;
return $self->val->{code};
}
# This only uses methods so is transparent to HASH or ARRAY
sub cmp
{
my $self = shift;
my $other = shift;
$self->time <=> $other->time;
}
0x55AA;
( run in 1.593 second using v1.01-cache-2.11-cpan-39bf76dae61 )