AnyEvent-RetryTimer
view release on metacpan or search on metacpan
lib/AnyEvent/RetryTimer.pm view on Meta::CPAN
package AnyEvent::RetryTimer;
use common::sense;
use Scalar::Util qw/weaken/;
use AnyEvent;
our $VERSION = '0.1';
=head1 NAME
AnyEvent::RetryTimer - Retry timers for AnyEvent
=head1 VERSION
lib/AnyEvent/RetryTimer.pm view on Meta::CPAN
multiplier => 1.5,
max_interval => 3600 * 4, # 6 hours
max_retries => 0, # infinite
start_interval => 10,
@_
};
bless $self, $class;
my $rself = $self;
weaken $self;
$self->{timer} = AE::timer 0, 0, sub {
delete $self->{timer};
$self->{on_retry}->($self) if $self;
};
return $rself
}
=item $timer->retry
lib/AnyEvent/RetryTimer.pm view on Meta::CPAN
will not cause the initial try to be "retried".
If you are interested in the length of the current interval (after a
call to this method), you can call the C<current_interval> method.
=cut
sub retry {
my ($self) = @_;
weaken $self;
return if $self->{timer};
if ($self->{backoff} eq 'exponential') {
my $r;
# layout of $r = [$interval, $retry_cnt]
if ($r = $self->{r}) {
if ($self->{max_retries}
( run in 0.596 second using v1.01-cache-2.11-cpan-65fba6d93b7 )