line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Database::Async::Backoff::Exponential; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
98
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.017'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
13
|
use parent qw(Database::Async::Backoff); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
107
|
use mro qw(c3); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
11
|
2
|
|
|
2
|
|
60
|
use Future::AsyncAwait; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
7
|
|
12
|
2
|
|
|
2
|
|
95
|
use List::Util qw(min); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
588
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Database::Async::Backoff->register( |
15
|
|
|
|
|
|
|
exponential => __PACKAGE__ |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
3
|
|
|
3
|
0
|
9
|
my ($class, %args) = @_; |
20
|
3
|
|
|
|
|
13
|
return $class->next::method( |
21
|
|
|
|
|
|
|
max_delay => 30, |
22
|
|
|
|
|
|
|
initial_delay => 0.05, |
23
|
|
|
|
|
|
|
%args |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub next { |
28
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
29
|
|
|
|
|
|
|
return $self->{delay} ||= min( |
30
|
|
|
|
|
|
|
$self->max_delay, |
31
|
0
|
|
0
|
|
|
|
(2 * ($self->{delay} // 0)) |
|
|
|
0
|
|
|
|
|
32
|
|
|
|
|
|
|
|| $self->initial_delay |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |