Remote/Future.pm

filter: Statementstmt 76.9% 50 / 65 Branchbran 56.2% 9 / 16 Conditioncond 46.6% 7 / 15 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 77.7% 14 / 18 Podpod 0.0% 0 / 6 totaltotal 64.8% 83 / 128 CC 23 SCAR 13.9
CC
23
Cov
69%
start
9.0
start
9.0
future
6.7
CRAP 4.0
« Remote/MiniLoop.pm ↑ Summary Remote/Handle.pm »
1 package Object::Remote::Future;
2  
3 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 15 ▶use Object::Remote::Logging qw( :log router );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 15 ▶BEGIN { router()->exclude_forwarding }
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 15 ▶use Future;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 our @EXPORT = qw(future await_future await_all);
14  
15 131 ▶sub future (&;$) {
Subroutine future: called CC=4 SCAR=19.1
Pod undocumented
16 0 ▶ my $f = $_[0]->(Object::Remote->current_loop->new_future);
Subroutine future: not called CC=4 SCAR=19.1
Pod undocumented
17 0 ▶ return $f if ((caller(1+($_[1]||0))||'') eq 'start');
Branch: 2 branches
BranchTrueFalseTotal
if (caller 1 + ($_[1] || 0) || "") eq "start" 0 0 0
if (caller 1 + ($_[1] || 0) || "") eq "start" 26 105 131
Condition37%3/8
caller 1 + ($_[1] || 0) || ''
l!l
00
$_[1] || 0
l!l
00
caller 1 + ($_[1] || 0) || ''
l!l
1310
$_[1] || 0
l!l
20111
MC/DC0%0/1
caller 1 + ($_[1] || 0) || ''
caller 1 + ($_[1] || 0)
MC/DC0%0/1
$_[1] || 0
$_[1]
MC/DC0%0/1
caller 1 + ($_[1] || 0) || ''
caller 1 + ($_[1] || 0)
MC/DC100%1/1
$_[1] || 0
$_[1]
Truth table0%0/2
A
A= caller 1 + ($_[1] || 0)
Aresult
11
00
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
Truth table50%1/2
A
A= caller 1 + ($_[1] || 0)
Aresult
11
00
Truth table100%2/2
A
A= $_[1]
Aresult
11
00
18 0 await_future($f);
19 }
20  
21 168 ▶sub await_future {
Subroutine await_future: called CC=2 SCAR=9.2
Pod undocumented
22 0 ▶ my $f = shift;
Subroutine await_future: not called CC=2 SCAR=9.2
Pod undocumented
23 0 Object::Remote->current_loop->await($f);
24 0 ▶ return wantarray ? $f->get : ($f->get)[0];
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 0 0 0
wantarray ? : 3 165 168
25 }
26  
27 2 ▶sub await_all {
Subroutine await_all: called CC=1 SCAR=0.2
Pod undocumented
28 0 ▶ log_trace { my $l = @_; "await_all() invoked with '$l' futures to wait on" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
Subroutine await_all: called CC=1 SCAR=0.2
Pod undocumented
29 20 Object::Remote->current_loop->await_all(@_);
30 13 map $_->get, @_;
31 }
32  
33 package # hide from PAUSE
34 start;
35  
36 our $start = sub { my ($obj, $call) = (shift, shift); $obj->$call(@_); };
37  
38 sub AUTOLOAD {
39 13 ▶ my $invocant = shift;
Subroutine AUTOLOAD: called CC=4 SCAR=14.4
40 13 my ($method) = our $AUTOLOAD =~ /^start::(.+)$/;
41 13 my $res;
42 13 ▶ unless (eval { $res = $invocant->$method(@_); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $res = $invocant->$method(@_); 1 } }) 0 13 13
43 0 my $f = Object::Remote->current_loop->new_future;
44 0 $f->fail($@);
45 13 return $f;
46 }
47 2 ▶ unless (Scalar::Util::blessed($res) and $res->isa('Future')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($res) and $res->isa("Future")) 2 11 13
Condition100%3/3
builtin::blessed($res) and $res->isa("Future")
!ll&&!rl&&r
1111
MC/DC100%2/2
builtin::blessed($res) and $res->isa("Future")
builtin::blessed($res) $res->isa("Future")
Truth table100%3/3
A and B
A= builtin::blessed($res)B= $res->isa("Future")
ABresult
0X0
100
111
48 2 my $f = Object::Remote->current_loop->new_future;
49 2 $f->done($res);
50 11 return $f;
51 }
52 0 return $res;
53 }
54  
55 package # hide from PAUSE
56 maybe;
57  
58 sub start {
59 0 ▶ my ($obj, $call) = (shift, shift);
Subroutine start: not called CC=3 SCAR=22.0
60 0 ▶ if ((caller(1)||'') eq 'start') {
Branch: 1 branch
BranchTrueFalseTotal
if ((caller 1 || '') eq 'start') { } 0 0 0
Condition0%0/2
caller 1 || ''
l!l
00
MC/DC0%0/1
caller 1 || ''
caller 1
Truth table0%0/2
A
A= caller 1
Aresult
11
00
61 0 $obj->$start::start($call => @_);
62 } else {
63 48 $obj->$call(@_);
64 }
65 }
66  
67 package # hide from PAUSE
68 maybe::start;
69  
70 sub AUTOLOAD {
71 48 ▶ my $invocant = shift;
Subroutine AUTOLOAD: called CC=3 SCAR=11.0
72 48 my ($method) = our $AUTOLOAD =~ /^maybe::start::(.+)$/;
73 48 ▶ $method = "start::${method}" if ((caller(1)||'') eq 'start');
Branch: 1 branch
BranchTrueFalseTotal
if (caller 1 || "") eq "start" 1 47 48
Condition50%1/2
caller 1 || ''
l!l
480
MC/DC0%0/1
caller 1 || ''
caller 1
Truth table50%1/2
A
A= caller 1
Aresult
11
00
74 2 $invocant->$method(@_);
75 }
76  
77 package # hide from PAUSE
78 then;
79  
80 sub AUTOLOAD {
81 2 ▶ my $invocant = shift;
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
82 2 my ($method) = our $AUTOLOAD =~ /^then::(.+)$/;
83 2 my @args = @_;
84 return $invocant->then(sub {
85 2 ▶ my ($obj) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
86 2 return $obj->${\"start::${method}"}(@args);
87 2 });
88 }
89  
90 1;
91  
92 =head1 NAME
93  
94 Object::Remote::Future - Asynchronous calling for L<Object::Remote>
95  
96 =head1 LAME
97  
98 Shipping prioritised over writing this part up. Blame mst.
99  
100 =cut
« Remote/MiniLoop.pm ↑ Summary Remote/Handle.pm »