line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package fs::Promises::Utils; |
2
|
2
|
|
|
2
|
|
1068
|
use v5.24; |
|
2
|
|
|
|
|
6
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
4
|
2
|
|
|
2
|
|
10
|
use AnyEvent (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
10
|
use AnyEvent::XSPromises (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
6
|
2
|
|
|
2
|
|
11
|
use Scalar::Util qw(blessed); |
|
2
|
|
|
|
|
21
|
|
|
2
|
|
|
|
|
123
|
|
7
|
2
|
|
|
2
|
|
13
|
use Exporter qw(import); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
723
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(await p_while then); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub await ($) { |
11
|
10
|
|
|
10
|
0
|
21
|
my $p = shift; |
12
|
10
|
|
|
|
|
266
|
my $cv = AnyEvent->condvar; |
13
|
|
|
|
|
|
|
$p->then( |
14
|
7
|
|
|
7
|
|
406
|
sub { $cv->send(@_) }, |
15
|
3
|
|
|
3
|
|
1661
|
sub { $cv->croak(@_) }, |
16
|
10
|
|
|
|
|
462
|
); |
17
|
10
|
|
|
|
|
44
|
return $cv->recv; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
0
|
0
|
sub then (&) { return $_[0] } |
21
|
|
|
|
|
|
|
sub p_while (&$) { |
22
|
1
|
|
|
1
|
0
|
1498
|
my ($while_cond, $cb) = @_; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
5
|
my $d = AnyEvent::XSPromises::deferred(); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub { |
27
|
86
|
|
|
86
|
|
157
|
my $do_while = __SUB__; |
28
|
86
|
|
|
|
|
175
|
my $cond = $while_cond->(); |
29
|
86
|
50
|
33
|
|
|
1570
|
$cond = AnyEvent::XSPromises::resolved($cond) if !blessed($cond) || !$cond->can('then'); |
30
|
|
|
|
|
|
|
return $cond->then(sub { |
31
|
86
|
100
|
|
|
|
338
|
return unless defined($_[0]); |
32
|
85
|
|
|
|
|
230
|
$cb->($_[0]); |
33
|
85
|
|
|
|
|
55828
|
$do_while->(); |
34
|
|
|
|
|
|
|
}) |
35
|
1
|
|
|
1
|
|
5
|
}->()->finally(sub { $d->resolve }); |
|
86
|
|
|
|
|
1106
|
|
|
1
|
|
|
|
|
10
|
|
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
28
|
return $d->promise; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|