line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Promise::ES6::EventLoopBase; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
510
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use parent qw(Promise::ES6); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
0
|
|
my ($class, $cr) = @_; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
return $class->SUPER::new( sub { |
12
|
0
|
|
|
0
|
|
|
my ($res, $rej) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
local $@; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my $rej_pp = $class->_create_postpone_cb($rej); |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $ok = eval { |
19
|
0
|
|
|
|
|
|
$cr->( |
20
|
|
|
|
|
|
|
$class->_create_postpone_cb($res), |
21
|
|
|
|
|
|
|
$rej_pp, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
if (!$ok) { |
28
|
0
|
|
|
|
|
|
$rej_pp->( my $err = $@ ); |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
} ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _create_postpone_cb { |
34
|
0
|
|
|
0
|
|
|
my ($class, $cr) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return sub { |
37
|
0
|
|
|
0
|
|
|
my ($arg) = @_; |
38
|
0
|
|
|
|
|
|
$class->_postpone( sub { $cr->($arg) } ); |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
}, |
40
|
0
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub then { |
43
|
0
|
|
|
0
|
0
|
|
my ($self, $on_res, $on_rej) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $class = ref $self; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return $class->new( sub { |
48
|
0
|
|
|
0
|
|
|
my ($y, $n) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$class->_postpone( sub { |
51
|
0
|
|
|
|
|
|
$self->SUPER::then($on_res, $on_rej)->SUPER::then($y, $n); |
52
|
0
|
|
|
|
|
|
} ); |
53
|
0
|
|
|
|
|
|
} ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub finally { |
57
|
0
|
|
|
0
|
0
|
|
my ($self, $on_finish) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $class = ref $self; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return $class->new( sub { |
62
|
0
|
|
|
0
|
|
|
my ($y, $n) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$class->_postpone( sub { |
65
|
0
|
|
|
|
|
|
$self->SUPER::finally($on_finish)->SUPER::then($y, $n); |
66
|
0
|
|
|
|
|
|
} ); |
67
|
0
|
|
|
|
|
|
} ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |