line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Promises6::Listener; |
2
|
28
|
|
|
28
|
|
758
|
use Evo::Base -base; |
|
28
|
|
|
|
|
36
|
|
|
28
|
|
|
|
|
243
|
|
3
|
28
|
|
|
28
|
|
5347
|
use Promises6::Util 'PROGRESS'; |
|
28
|
|
|
|
|
50
|
|
|
28
|
|
|
|
|
8379
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has [qw(deferred builder)]; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# onFulfill, onReject, onProgress |
8
|
|
|
|
|
|
|
has cbs => sub { [] }; |
9
|
|
|
|
|
|
|
|
10
|
173
|
50
|
|
173
|
1
|
339
|
sub get_msg($self, $state, $val) { |
|
173
|
50
|
|
|
|
283
|
|
|
173
|
|
|
|
|
167
|
|
|
173
|
|
|
|
|
143
|
|
|
173
|
|
|
|
|
161
|
|
|
173
|
|
|
|
|
142
|
|
11
|
173
|
|
|
|
|
3276
|
my $deferred = $self->deferred; |
12
|
173
|
|
|
|
|
3244
|
my $cb = $self->cbs->[$state]; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# then. 1.i, 1.ii |
15
|
173
|
100
|
|
|
|
1072
|
unless (ref $cb eq 'CODE') { |
16
|
29
|
100
|
|
|
|
115
|
$state == PROGRESS |
17
|
|
|
|
|
|
|
? $deferred->notify($val) |
18
|
|
|
|
|
|
|
: $deferred->change_state($state, $val); |
19
|
29
|
|
|
|
|
1432
|
return; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# then 7.ii |
23
|
144
|
|
|
|
|
140
|
my $err; |
24
|
144
|
|
|
|
|
171
|
CATCH: { |
25
|
144
|
|
|
|
|
123
|
local $@; |
26
|
144
|
|
|
|
|
170
|
$val = eval { $cb->($val) }; |
|
144
|
|
|
|
|
346
|
|
27
|
144
|
|
|
|
|
17390
|
$err = $@; |
28
|
|
|
|
|
|
|
} |
29
|
144
|
100
|
|
|
|
298
|
return $deferred->reject($err) if $err; |
30
|
|
|
|
|
|
|
|
31
|
142
|
100
|
|
|
|
536
|
$state == PROGRESS ? $deferred->notify($val) : $deferred->resolve($val); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# ABSTRACT: A listener. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |