| 1 | # You may distribute under the terms of either the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # or the Artistic License (the same terms as Perl itself) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # (C) Paul Evans, 2011-2026 -- leonerd@leonerd.org.uk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | package Future::PP 0.54; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 33 | ▶ | use v5.20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 33 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 33 | ▶ | no warnings 'recursion'; # Disable the "deep recursion" warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 33 | ▶ | use feature qw( postderef signatures ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 33 | ▶ | no warnings qw( experimental::postderef experimental::signatures ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 33 | our @ISA = qw( Future::_base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 33 | ▶ | use Carp qw(); # don't import croak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 33 | ▶ | use List::Util 1.29 qw( pairs pairkeys ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 33 | ▶ | use Scalar::Util qw( weaken blessed reftype ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 33 | ▶ | use Time::HiRes qw( gettimeofday ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 33 | our @CARP_NOT = qw( Future Future::_base Future::Utils ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 33 | ▶ | use constant DEBUG => !!$ENV{PERL_FUTURE_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 33 | ▶ | use constant STRICT => !!$ENV{PERL_FUTURE_STRICT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # Callback flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 33 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 33 | CB_DONE => 1<<0, # Execute callback on done | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | CB_FAIL => 1<<1, # Execute callback on fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | CB_CANCEL => 1<<2, # Execute callback on cancellation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | CB_SELF => 1<<3, # Pass $self as first argument | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | CB_RESULT => 1<<4, # Pass result/failure as a list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | CB_SEQ_ONDONE => 1<<5, # Sequencing on success (->then) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | CB_SEQ_ONFAIL => 1<<6, # Sequencing on failure (->else) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | CB_SEQ_IMDONE => 1<<7, # $code is in fact immediate ->done result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | CB_SEQ_IMFAIL => 1<<8, # $code is in fact immediate ->fail result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | CB_SEQ_STRICT => 1<<9, # Complain if $code didn't return a Future | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 33 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 33 | ▶ | use constant CB_ALWAYS => CB_DONE|CB_FAIL|CB_CANCEL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | ▶ | sub _shortmess ( $msg ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shortmess: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | my $at = Carp::shortmess( $msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | chomp $at; $at =~ s/\.$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | return $at; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 486 | ▶ | sub _callable ( $cb ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_callable: called CC=3 SCAR=15.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 486 | ▶ | defined $cb and ( reftype($cb) eq 'CODE' || overload::Method($cb, '&{}') ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $cb && (builtin::reftype($cb) eq 'CODE' || overload::Method($cb, '&{}'))
builtin::reftype($cb) eq "CODE" or overload::Method($cb, "&{}")
MC/DC0%0/3
defined $cb && (builtin::reftype($cb) eq 'CODE' || overload::Method($cb, '&{}'))
defined $cb
builtin::reftype($cb) eq "CODE"
overload::Method($cb, "&{}")
Truth table25%1/4
A && B or C
A= defined $cbB= builtin::reftype($cb) eq "CODE"C= overload::Method($cb, "&{}")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 721 | ▶ | sub new ( $proto ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | return bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ready => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | callbacks => [], # [] = [$type, ...] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ( DEBUG ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 721 | ▶ | ( do { my $at = Carp::shortmess( "constructed" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table66%2/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | chomp $at; $at =~ s/\.$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | constructed_at => $at } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ( $Future::TIMES ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ( btime => [ gettimeofday ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | }, ( ref $proto || $proto ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 12 | ▶ | sub __selfstr ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__selfstr: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 20 | my $str = "$self"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 20 | ▶ | $str .= " (\"$self->{label}\")" if defined $self->{label}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 20 | ▶ | $str .= " ($self->{constructed_at})" if defined $self->{constructed_at}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 20 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 33 | my $GLOBAL_END; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 33 | ▶ | END { $GLOBAL_END = 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | ▶ | sub DESTROY_debug ( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY_debug: called CC=8 SCAR=21.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 8 | ▶ | return if $GLOBAL_END; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 8 | ▶ | return if $self->{ready} and ( $self->{reported} or !$self->{failure} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->{"ready"} and $self->{"reported"} || !$self->{"failure"}
$self->{"reported"} or not $self->{"failure"}
MC/DC66%2/3
$self->{"ready"} and $self->{"reported"} || !$self->{"failure"}
$self->{"ready"}
$self->{"reported"}
not $self->{"failure"}
Truth table75%3/4
A and B or not(C)
A= $self->{"ready"}B= $self->{"reported"}C= not $self->{"failure"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 3 | my $lost_at = join " line ", (caller)[1,2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # We can't actually know the real line where the last reference was lost; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # a variable set to 'undef' or close of scope, because caller can't see it; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # the current op has already been updated. The best we can do is indicate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # 'near'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | if( $self->{ready} and $self->{failure} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$self->{"ready"} and $self->{"failure"}
MC/DC50%1/2
$self->{"ready"} and $self->{"failure"}
$self->{"ready"}
$self->{"failure"}
Truth table66%2/3
A and B
A= $self->{"ready"}B= $self->{"failure"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | warn "${\$self->__selfstr} was lost near $lost_at with an unreported failure of: " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | $self->{failure}[0] . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | elsif( !$self->{ready} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | warn "${\$self->__selfstr} was lost near $lost_at before it was ready.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 33 | *DESTROY = \&DESTROY_debug if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 477 | ▶ | sub is_ready ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ready: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 477 | return $self->{ready}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 79 | ▶ | sub is_done ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_done: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 79 | ▶ | return $self->{ready} && !$self->{failure} && !$self->{cancelled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$self->{'ready'} && !$self->{'failure'} && !$self->{'cancelled'}
$self->{"ready"} and not $self->{"failure"}
MC/DC66%2/3
$self->{'ready'} && !$self->{'failure'} && !$self->{'cancelled'}
$self->{"ready"}
not $self->{"failure"}
!$self->{'cancelled'}
Truth table75%3/4
A and not(B) && not(C)
A= $self->{"ready"}B= not $self->{"failure"}C= !$self->{'cancelled'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 9 | ▶ | sub is_failed ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_failed: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 9 | ▶ | return $self->{ready} && !!$self->{failure}; # boolify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->{'ready'} && !!$self->{'failure'}
MC/DC100%2/2
$self->{'ready'} && !!$self->{'failure'}
$self->{'ready'}
!!$self->{'failure'}
Truth table100%3/3
A && B
A= $self->{'ready'}B= !!$self->{'failure'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 38 | ▶ | sub is_cancelled ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_cancelled: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 38 | return $self->{cancelled}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 8 | ▶ | sub state ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | return !$self->{ready} ? "pending" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | DEBUG ? $self->{ready_at} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | $self->{failure} ? "failed" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 8 | ▶ | $self->{cancelled} ? "cancelled" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | "done"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 561 | ▶ | sub _mark_ready ( $self, $reason ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_ready: called CC=38 SCAR=36.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 561 | $self->{ready} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 561 | $self->{ready_at} = _shortmess $reason if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 561 | ▶ | if( $Future::TIMES ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 4 | $self->{rtime} = [ gettimeofday ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 561 | delete $self->{on_cancel}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 561 | ▶ | $_->[0] and $_->[0]->_revoke_on_cancel( $_->[1] ) for $self->{revoke_when_ready}->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 561 | delete $self->{revoke_when_ready}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 561 | ▶ | my $callbacks = delete $self->{callbacks} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 556 | my $cancelled = $self->{cancelled}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 556 | my $fail = defined $self->{failure}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 556 | ▶ | my $done = !$fail && !$cancelled; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$fail || $cancelled
MC/DC100%2/2
$fail || $cancelled
$fail
$cancelled
Truth table100%3/3
A || B
A= $failB= $cancelled
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | my @result = $done ? $self->{result}->@* : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | $fail ? $self->{failure}->@* : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 556 | ▶ | (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 556 | foreach my $cb ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 341 | my ( $flags, $code ) = @$cb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 341 | ▶ | my $is_future = blessed( $code ) && $code->isa( "Future" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($code) && $code->isa('Future')
MC/DC50%1/2
builtin::blessed($code) && $code->isa('Future')
builtin::blessed($code)
$code->isa('Future')
Truth table66%2/3
A && B
A= builtin::blessed($code)B= $code->isa('Future')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 341 | ▶ | next if $done and not( $flags & CB_DONE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$done and not $flags & 1
MC/DC100%2/2
$done and not $flags & 1
$done
not $flags & 1
Truth table100%3/3
A and not(B)
A= $doneB= not $flags & 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 301 | ▶ | next if $fail and not( $flags & CB_FAIL ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$fail and not $flags & 2
MC/DC100%2/2
$fail and not $flags & 2
$fail
not $flags & 2
Truth table100%3/3
A and not(B)
A= $failB= not $flags & 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 298 | ▶ | next if $cancelled and not( $flags & CB_CANCEL ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$cancelled and not $flags & 4
MC/DC100%2/2
$cancelled and not $flags & 4
$cancelled
not $flags & 4
Truth table100%3/3
A and not(B)
A= $cancelledB= not $flags & 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 266 | ▶ | $self->{reported} = 1 if $fail; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 266 | ▶ | if( $is_future ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 23 | ▶ | $done ? $code->done( @result ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | $fail ? $code->fail( @result ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | $code->cancel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | elsif( $flags & (CB_SEQ_ONDONE|CB_SEQ_ONFAIL) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 60 | my ( undef, undef, $fseq ) = @$cb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 60 | ▶ | if( !$fseq ) { # weaken()ed; it might be gone now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # This warning should always be printed, even not in DEBUG mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # It's always an indication of a bug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | Carp::carp "${\$self->__selfstr} lost a sequence Future"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 58 | my $f2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 58 | ▶ | if( $done and $flags & CB_SEQ_ONDONE or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$done and $flags & 32 or $fail and $flags & 64
$done and $flags & 32
$fail and $flags & 64
MC/DC75%3/4
$done and $flags & 32 or $fail and $flags & 64
$done
$flags & 32
$fail
$flags & 64
Truth table57%4/7
A and B or C and D
A= $doneB= $flags & 32C= $failD= $flags & 64
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | $fail and $flags & CB_SEQ_ONFAIL ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 52 | ▶ | if( $flags & CB_SEQ_IMDONE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | $fseq->done( @$code ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | elsif( $flags & CB_SEQ_IMFAIL ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | $fseq->fail( @$code ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 48 | ▶ | my @args = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ( $flags & CB_SELF ? $self : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | ( $flags & CB_RESULT ? @result : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 48 | ▶ | unless( eval { $f2 = $code->( @args ); 1 } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | $fseq->fail( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 44 | ▶ | unless( blessed $f2 and $f2->isa( "Future" ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($f2) and $f2->isa("Future")
MC/DC50%1/2
builtin::blessed($f2) and $f2->isa("Future")
builtin::blessed($f2)
$f2->isa("Future")
Truth table66%2/3
A and B
A= builtin::blessed($f2)B= $f2->isa("Future")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # Upgrade a non-Future result, or complain in strict mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 3 | ▶ | if( $flags & CB_SEQ_STRICT ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $fseq->fail( "Expected " . Future::CvNAME_FILE_LINE($code) . " to return a Future" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | $f2 = Future->done( $f2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 44 | $fseq->on_cancel( $f2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | $f2 = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 50 | ▶ | if( $f2->is_ready ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 30 | ▶ | $f2->on_ready( $fseq ) if !$f2->{cancelled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 20 | push $f2->{callbacks}->@*, [ CB_DONE|CB_FAIL, $fseq ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 20 | weaken( $f2->{callbacks}[-1][1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 183 | ▶ | $code->( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | ( $flags & CB_SELF ? $self : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | ( $flags & CB_RESULT ? @result : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 408 | ▶ | sub done ( $self, @result ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
done: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 408 | ▶ | if( ref $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 316 | ▶ | $self->{cancelled} and return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 313 | ▶ | $self->{ready} and Carp::croak "${\$self->__selfstr} is already ".$self->state." and cannot be ->done"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | $self->{subs} and Carp::croak "${\$self->__selfstr} is not a leaf Future, cannot be ->done"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 311 | $self->{result} = [ @result ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 311 | $self->_mark_ready( "done" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 92 | $self = $self->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 92 | $self->{ready} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 92 | $self->{ready_at} = _shortmess "done" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 92 | $self->{result} = [ @result ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 92 | ▶ | if( $Future::TIMES ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | $self->{rtime} = [ gettimeofday ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 403 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 143 | ▶ | sub fail ( $self, $exception, @more ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fail: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 143 | ▶ | if( ref $exception eq "Future::Exception" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | @more = ( $exception->category, $exception->details ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | $exception = $exception->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 143 | ▶ | $exception or Carp::croak "$self ->fail requires an exception that is true"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 143 | ▶ | if( ref $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 87 | ▶ | $self->{cancelled} and return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 86 | ▶ | $self->{ready} and Carp::croak "${\$self->__selfstr} is already ".$self->state." and cannot be ->fail'ed"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | $self->{subs} and Carp::croak "${\$self->__selfstr} is not a leaf Future, cannot be ->fail'ed"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 84 | $self->{failure} = [ $exception, @more ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 84 | $self->_mark_ready( "failed" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 56 | $self = $self->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 56 | $self->{ready} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 56 | $self->{ready_at} = _shortmess "failed" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 56 | $self->{failure} = [ $exception, @more ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 56 | ▶ | if( $Future::TIMES ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | $self->{rtime} = [ gettimeofday ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 140 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 338 | ▶ | sub on_cancel ( $self, $code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_cancel: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 338 | ▶ | my $is_future = blessed( $code ) && $code->isa( "Future" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($code) && $code->isa('Future')
MC/DC50%1/2
builtin::blessed($code) && $code->isa('Future')
builtin::blessed($code)
$code->isa('Future')
Truth table66%2/3
A && B
A= builtin::blessed($code)B= $code->isa('Future')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 338 | ▶ | $is_future or _callable( $code ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$is_future or _callable($code)
MC/DC0%0/2
$is_future or _callable($code)
$is_future
_callable($code)
Truth table66%2/3
A or B
A= $is_futureB= _callable($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | Carp::croak "Expected \$code to be callable or a Future in ->on_cancel"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 338 | ▶ | $self->{ready} and return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 315 | push $self->{on_cancel}->@*, $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 315 | ▶ | if( $is_future ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 219 | push $code->{revoke_when_ready}->@*, my $r = [ $self, \$self->{on_cancel}[-1] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 219 | weaken( $r->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 219 | weaken( $r->[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 315 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # An optimised version for Awaitable role | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | sub AWAIT_ON_CANCEL ( $self, $code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AWAIT_ON_CANCEL: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | push $self->{on_cancel}->@*, $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub AWAIT_CHAIN_CANCEL ( $self, $f2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AWAIT_CHAIN_CANCEL: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | push $self->{on_cancel}->@*, $f2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | push $f2->{revoke_when_ready}->@*, my $r = [ $self, \$self->{on_cancel}[-1] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | weaken( $r->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | weaken( $r->[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 192 | ▶ | sub _revoke_on_cancel ( $self, $ref ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_revoke_on_cancel: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 192 | undef $$ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 192 | $self->{empty_on_cancel_slots}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 192 | ▶ | my $on_cancel = $self->{on_cancel} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # If the list is nontrivally large and over half-empty / under half-full, compact it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 172 | ▶ | if( @$on_cancel >= 8 and $self->{empty_on_cancel_slots} >= 0.5 * @$on_cancel ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$on_cancel >= 8 and $self->{"empty_on_cancel_slots"} >= "0.5" * @$on_cancel
MC/DC100%2/2
@$on_cancel >= 8 and $self->{"empty_on_cancel_slots"} >= "0.5" * @$on_cancel
@$on_cancel >= 8
$self->{"empty_on_cancel_slots"} >= "0.5" * @$on_cancel
Truth table100%3/3
A and B
A= @$on_cancel >= 8B= $self->{"empty_on_cancel_slots"} >= "0.5" * @$on_cancel
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # We can't grep { defined } because that will break all the existing SCALAR refs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 3 | my $idx = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | ▶ | while( $idx < @$on_cancel ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 175 | ▶ | defined $on_cancel->[$idx] and $idx++, next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 88 | splice @$on_cancel, $idx, 1, (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 3 | $self->{empty_on_cancel_slots} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 179 | ▶ | sub on_ready ( $self, $code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_ready: called CC=10 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 179 | ▶ | my $is_future = blessed( $code ) && $code->isa( "Future" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($code) && $code->isa('Future')
MC/DC50%1/2
builtin::blessed($code) && $code->isa('Future')
builtin::blessed($code)
$code->isa('Future')
Truth table66%2/3
A && B
A= builtin::blessed($code)B= $code->isa('Future')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 179 | ▶ | $is_future or _callable( $code ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$is_future or _callable($code)
MC/DC0%0/2
$is_future or _callable($code)
$is_future
_callable($code)
Truth table66%2/3
A or B
A= $is_futureB= _callable($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | Carp::croak "Expected \$code to be callable or a Future in ->on_ready"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 179 | ▶ | if( $self->{ready} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 40 | my $fail = defined $self->{failure}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 40 | ▶ | my $done = !$fail && !$self->{cancelled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$fail || $self->{'cancelled'}
MC/DC100%2/2
$fail || $self->{'cancelled'}
$fail
$self->{'cancelled'}
Truth table100%3/3
A || B
A= $failB= $self->{'cancelled'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 40 | ▶ | $self->{reported} = 1 if $fail; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | $is_future ? ( $done ? $code->done( $self->{result}->@* ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 40 | ▶ | $fail ? $code->fail( $self->{failure}->@* ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | $code->cancel ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | : $code->( $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 139 | push $self->{callbacks}->@*, [ CB_ALWAYS|CB_SELF, $self->wrap_cb( on_ready => $code ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 179 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # An optimised version for Awaitable role | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub AWAIT_ON_READY ( $self, $code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AWAIT_ON_READY: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | push $self->{callbacks}->@*, [ CB_ALWAYS|CB_SELF, $self->wrap_cb( on_ready => $code ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 91 | ▶ | sub result ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | $self->{ready} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 91 | ▶ | Carp::croak( "${\$self->__selfstr} is not yet ready" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 90 | ▶ | if( my $failure = $self->{failure} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 9 | $self->{reported} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 9 | my $exception = $failure->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 9 | ▶ | $exception = Future::Exception->new( @$failure ) if @$failure > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 9 | ▶ | !ref $exception && $exception =~ m/\n$/ ? CORE::die $exception : Carp::croak $exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $exception and $exception =~ /\n$/u
MC/DC100%2/2
not ref $exception and $exception =~ /\n$/u
not ref $exception
$exception =~ /\n$/u
Truth table100%3/3
not(A) and B
A= not ref $exceptionB= $exception =~ /\n$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 81 | ▶ | $self->{cancelled} and Carp::croak "${\$self->__selfstr} was cancelled"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 79 | ▶ | return $self->{result}->[0] unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 38 | return $self->{result}->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 10 | ▶ | sub get ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 10 | ▶ | $self->await unless $self->{ready}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 9 | return $self->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 4 | ▶ | sub await ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
await: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 4 | ▶ | return $self if $self->{ready}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | Carp::croak "$self is not yet complete and does not provide ->await"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 90 | ▶ | sub on_done ( $self, $code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_done: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 90 | ▶ | my $is_future = blessed( $code ) && $code->isa( "Future" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($code) && $code->isa('Future')
MC/DC50%1/2
builtin::blessed($code) && $code->isa('Future')
builtin::blessed($code)
$code->isa('Future')
Truth table66%2/3
A && B
A= builtin::blessed($code)B= $code->isa('Future')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 90 | ▶ | $is_future or _callable( $code ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$is_future or _callable($code)
MC/DC0%0/2
$is_future or _callable($code)
$is_future
_callable($code)
Truth table66%2/3
A or B
A= $is_futureB= _callable($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | Carp::croak "Expected \$code to be callable or a Future in ->on_done"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 90 | ▶ | if( $self->{ready} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 27 | ▶ | return $self if $self->{failure} or $self->{cancelled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"failure"} or $self->{"cancelled"}
MC/DC100%2/2
$self->{"failure"} or $self->{"cancelled"}
$self->{"failure"}
$self->{"cancelled"}
Truth table100%3/3
A or B
A= $self->{"failure"}B= $self->{"cancelled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | $is_future ? $code->done( $self->{result}->@* ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 15 | ▶ | : $code->( $self->{result}->@* ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 63 | push $self->{callbacks}->@*, [ CB_DONE|CB_RESULT, $self->wrap_cb( on_done => $code ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 78 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 144 | ▶ | sub failure ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
failure: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 144 | ▶ | $self->await unless $self->{ready}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 144 | ▶ | return unless $self->{failure}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 86 | $self->{reported} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 86 | ▶ | return $self->{failure}->[0] if !wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 17 | return $self->{failure}->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 88 | ▶ | sub on_fail ( $self, $code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_fail: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 88 | ▶ | my $is_future = blessed( $code ) && $code->isa( "Future" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($code) && $code->isa('Future')
MC/DC50%1/2
builtin::blessed($code) && $code->isa('Future')
builtin::blessed($code)
$code->isa('Future')
Truth table66%2/3
A && B
A= builtin::blessed($code)B= $code->isa('Future')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 88 | ▶ | $is_future or _callable( $code ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$is_future or _callable($code)
MC/DC0%0/2
$is_future or _callable($code)
$is_future
_callable($code)
Truth table66%2/3
A or B
A= $is_futureB= _callable($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | Carp::croak "Expected \$code to be callable or a Future in ->on_fail"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 88 | ▶ | if( $self->{ready} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 30 | ▶ | return $self if not $self->{failure}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 12 | $self->{reported} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | $is_future ? $code->fail( $self->{failure}->@* ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 12 | ▶ | : $code->( $self->{failure}->@* ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 58 | push $self->{callbacks}->@*, [ CB_FAIL|CB_RESULT, $self->wrap_cb( on_fail => $code ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 70 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 121 | ▶ | sub cancel ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cancel: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 121 | ▶ | return $self if $self->{ready}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 113 | $self->{cancelled}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 113 | my $on_cancel = delete $self->{on_cancel}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 113 | ▶ | foreach my $code ( $on_cancel ? reverse @$on_cancel : () ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 59 | ▶ | defined $code or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 46 | ▶ | my $is_future = blessed( $code ) && $code->isa( "Future" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($code) && $code->isa('Future')
MC/DC50%1/2
builtin::blessed($code) && $code->isa('Future')
builtin::blessed($code)
$code->isa('Future')
Truth table66%2/3
A && B
A= builtin::blessed($code)B= $code->isa('Future')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 46 | ▶ | $is_future ? $code->cancel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | : $code->( $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 113 | $self->_mark_ready( "cancel" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 113 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 21 | ▶ | my $make_donecatchfail_sub = sub ( $with_f, $done_code, $fail_code, @catch_list ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 21 | my $func = (caller 1)[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 21 | $func =~ s/^.*:://; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 21 | ▶ | !$done_code or _callable( $done_code ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $done_code or _callable($done_code)
MC/DC0%0/2
not $done_code or _callable($done_code)
not $done_code
_callable($done_code)
Truth table66%2/3
not(A) or B
A= not $done_codeB= _callable($done_code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | Carp::croak "Expected \$done_code to be callable in ->$func"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 21 | ▶ | !$fail_code or _callable( $fail_code ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $fail_code or _callable($fail_code)
MC/DC0%0/2
not $fail_code or _callable($fail_code)
not $fail_code
_callable($fail_code)
Truth table66%2/3
not(A) or B
A= not $fail_codeB= _callable($fail_code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | Carp::croak "Expected \$fail_code to be callable in ->$func"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 21 | my %catch_handlers = @catch_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | _callable( $catch_handlers{$_} ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | Carp::croak "Expected catch handler for '$_' to be callable in ->$func" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 21 | ▶ | for keys %catch_handlers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 19 | ▶ | sub ( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 19 | ▶ | my @maybe_self = $with_f ? ( $self ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 19 | ▶ | if( !$self->{failure} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 10 | ▶ | return $self unless $done_code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 7 | return $done_code->( @maybe_self, $self->{result}->@* ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 9 | my $name = $self->{failure}[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 9 | ▶ | if( defined $name and $catch_handlers{$name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $name and $catch_handlers{$name}
MC/DC100%2/2
defined $name and $catch_handlers{$name}
defined $name
$catch_handlers{$name}
Truth table100%3/3
A and B
A= defined $nameB= $catch_handlers{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 4 | return $catch_handlers{$name}->( @maybe_self, $self->{failure}->@* ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 5 | ▶ | return $self unless $fail_code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 3 | return $fail_code->( @maybe_self, $self->{failure}->@* ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 21 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 33 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 113 | ▶ | sub _sequence ( $f1, $code, $flags ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sequence: called CC=21 SCAR=30.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 113 | $flags |= CB_SEQ_STRICT if STRICT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # For later, we might want to know where we were called from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 113 | my $level = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 113 | ▶ | $level++ while (caller $level)[0] eq "Future::_base"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 113 | my $func = (caller $level)[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 113 | $func =~ s/^.*:://; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 113 | ▶ | $flags & (CB_SEQ_IMDONE|CB_SEQ_IMFAIL) or _callable( $code ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$flags & 384 or _callable($code)
MC/DC0%0/2
$flags & 384 or _callable($code)
$flags & 384
_callable($code)
Truth table66%2/3
A or B
A= $flags & 384B= _callable($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | Carp::croak "Expected \$code to be callable in ->$func"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 113 | ▶ | if( !defined wantarray ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 4 | Carp::carp "Calling ->$func in void context"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 113 | ▶ | if( $f1->is_ready ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # Take a shortcut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | return $f1 if $f1->is_done and not( $flags & CB_SEQ_ONDONE ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 40 | ▶ | $f1->{failure} and not( $flags & CB_SEQ_ONFAIL ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$f1->is_done and not $flags & 32 or $f1->{"failure"} and not $flags & 64
$f1->is_done and not $flags & 32
$f1->{"failure"} and not $flags & 64
MC/DC75%3/4
$f1->is_done and not $flags & 32 or $f1->{"failure"} and not $flags & 64
$f1->is_done
not $flags & 32
$f1->{"failure"}
not $flags & 64
Truth table57%4/7
A and not(B) or C and not(D)
A= $f1->is_doneB= not $flags & 32C= $f1->{"failure"}D= not $flags & 64
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 37 | ▶ | if( $flags & CB_SEQ_IMDONE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 2 | return Future->done( @$code ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | elsif( $flags & CB_SEQ_IMFAIL ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 2 | return Future->fail( @$code ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | my @args = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | ( $flags & CB_SELF ? $f1 : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | ( $flags & CB_RESULT ? $f1->is_done ? $f1->{result}->@* : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | $f1->{failure} ? $f1->{failure}->@* : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 33 | ▶ | () : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 33 | my $fseq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 33 | ▶ | unless( eval { $fseq = $code->( @args ); 1 } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 2 | return Future->fail( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 31 | ▶ | unless( blessed $fseq and $fseq->isa( "Future" ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($fseq) and $fseq->isa("Future")
MC/DC50%1/2
builtin::blessed($fseq) and $fseq->isa("Future")
builtin::blessed($fseq)
$fseq->isa("Future")
Truth table66%2/3
A and B
A= builtin::blessed($fseq)B= $fseq->isa("Future")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | # Upgrade a non-Future result, or complain in strict mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 8 | ▶ | $flags & CB_SEQ_STRICT and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | return Future->fail( "Expected " . Future::CvNAME_FILE_LINE($code) . " to return a Future" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 8 | $fseq = $f1->new->done( $fseq ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 31 | return $fseq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 73 | my $fseq = $f1->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 73 | $fseq->on_cancel( $f1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # TODO: if anyone cares about the op name, we might have to synthesize it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # from $flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 73 | ▶ | $code = $f1->wrap_cb( sequence => $code ) unless $flags & (CB_SEQ_IMDONE|CB_SEQ_IMFAIL); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 73 | push $f1->{callbacks}->@*, [ CB_DONE|CB_FAIL|$flags, $code, $fseq ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 73 | weaken( $f1->{callbacks}[-1][2] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 73 | return $fseq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 50 | ▶ | sub then ( $self, $done_code = undef, @catch_list ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
then: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 50 | ▶ | my $fail_code = ( @catch_list % 2 ) ? pop @catch_list : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 50 | ▶ | if( $done_code and !@catch_list and !$fail_code ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$done_code and not @catch_list and not $fail_code
$done_code and not @catch_list
MC/DC100%3/3
$done_code and not @catch_list and not $fail_code
$done_code
not @catch_list
not $fail_code
Truth table100%4/4
A and not(B) and not(C)
A= $done_codeB= not @catch_listC= not $fail_code
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 43 | return $self->_sequence( $done_code, CB_SEQ_ONDONE|CB_RESULT ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # Complex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 7 | return $self->_sequence( $make_donecatchfail_sub->( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0, $done_code, $fail_code, @catch_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | ), CB_SEQ_ONDONE|CB_SEQ_ONFAIL|CB_SELF ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 3 | ▶ | sub then_done ( $self, @result ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
then_done: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 3 | return $self->_sequence( \@result, CB_SEQ_ONDONE|CB_SEQ_IMDONE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 3 | ▶ | sub then_fail ( $self, @failure ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
then_fail: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 3 | return $self->_sequence( \@failure, CB_SEQ_ONDONE|CB_SEQ_IMFAIL ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 15 | ▶ | sub else ( $self, $fail_code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
else: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 15 | return $self->_sequence( $fail_code, CB_SEQ_ONFAIL|CB_RESULT ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 3 | ▶ | sub else_done ( $self, @result ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
else_done: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 3 | return $self->_sequence( \@result, CB_SEQ_ONFAIL|CB_SEQ_IMDONE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 3 | ▶ | sub else_fail ( $self, @failure ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
else_fail: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 3 | return $self->_sequence( \@failure, CB_SEQ_ONFAIL|CB_SEQ_IMFAIL ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 5 | ▶ | sub catch ( $self, @catch_list ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
catch: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 5 | ▶ | my $fail_code = ( @catch_list % 2 ) ? pop @catch_list : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 5 | return $self->_sequence( $make_donecatchfail_sub->( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0, undef, $fail_code, @catch_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | ), CB_SEQ_ONDONE|CB_SEQ_ONFAIL|CB_SELF ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 11 | ▶ | sub then_with_f ( $self, $done_code, @catch_list ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
then_with_f: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 11 | ▶ | my $fail_code = ( @catch_list % 2 ) ? pop @catch_list : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 11 | ▶ | if( $done_code and !@catch_list and !$fail_code ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$done_code and not @catch_list and not $fail_code
$done_code and not @catch_list
MC/DC66%2/3
$done_code and not @catch_list and not $fail_code
$done_code
not @catch_list
not $fail_code
Truth table75%3/4
A and not(B) and not(C)
A= $done_codeB= not @catch_listC= not $fail_code
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 3 | return $self->_sequence( $done_code, CB_SEQ_ONDONE|CB_SELF|CB_RESULT ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 8 | return $self->_sequence( $make_donecatchfail_sub->( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 1, $done_code, $fail_code, @catch_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | ), CB_SEQ_ONDONE|CB_SEQ_ONFAIL|CB_SELF ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 3 | ▶ | sub else_with_f ( $self, $fail_code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
else_with_f: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 3 | return $self->_sequence( $fail_code, CB_SEQ_ONFAIL|CB_SELF|CB_RESULT ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 1 | ▶ | sub catch_with_f ( $self, @catch_list ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
catch_with_f: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 1 | ▶ | my $fail_code = ( @catch_list % 2 ) ? pop @catch_list : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | return $self->_sequence( $make_donecatchfail_sub->( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 1, undef, $fail_code, @catch_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | ), CB_SEQ_ONDONE|CB_SEQ_ONFAIL|CB_SELF ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 16 | ▶ | sub followed_by ( $self, $code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
followed_by: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 16 | return $self->_sequence( $code, CB_SEQ_ONDONE|CB_SEQ_ONFAIL|CB_SELF ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 4 | ▶ | sub without_cancel ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
without_cancel: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 4 | my $new = $self->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 4 | ▶ | $self->on_ready( sub ( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 4 | ▶ | if( $self->{cancelled} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1 | $new->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | elsif( $self->{failure} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | $new->fail( $self->{failure}->@* ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 3 | $new->done( $self->{result}->@* ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 4 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 4 | $new->{orig} = $self; # just to strongref it - RT122920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 4 | ▶ | $new->on_ready( sub ( $self ) { undef $self->{orig} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 4 | return $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # $self->{subs} is an even-sized list of *pairs*, ( $subf, $flags, $subf, $flags, ... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # pairkeys @{ $self->{subs} } yields just the futures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 33 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 33 | SUBFLAG_NO_CANCEL => (1<<0), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 33 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 57 | ▶ | sub _new_convergent ( $, $subs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_convergent: called CC=9 SCAR=22.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 57 | my @flaggedsubs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 57 | ▶ | for ( my $i = 0; $i < @$subs; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 101 | my $flags = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 101 | ▶ | $flags |= SUBFLAG_NO_CANCEL, $i++ if !blessed $subs->[$i] and $subs->[$i] eq "also"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not builtin::blessed($subs->[$i]) and $subs->[$i] eq "also"
MC/DC50%1/2
not builtin::blessed($subs->[$i]) and $subs->[$i] eq "also"
not builtin::blessed($subs->[$i])
$subs->[$i] eq "also"
Truth table66%2/3
not(A) and B
A= not builtin::blessed($subs->[$i])B= $subs->[$i] eq "also"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 101 | my $sub = $subs->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 101 | ▶ | blessed $sub and $sub->isa( "Future" ) or Carp::croak "Expected a Future, got $sub"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($sub) and $sub->isa("Future")
MC/DC0%0/2
builtin::blessed($sub) and $sub->isa("Future")
builtin::blessed($sub)
$sub->isa("Future")
Truth table33%1/3
A and B
A= builtin::blessed($sub)B= $sub->isa("Future")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 101 | push @flaggedsubs, ( $sub, $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # Find the best prototype. Ideally anything derived if we can find one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 57 | my $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 57 | ▶ | ref($_) eq "Future" or $self = $_->new, last for pairkeys @flaggedsubs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | # No derived ones; just have to be a basic class then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 57 | ▶ | $self ||= Future->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self ||= "Future"->new
MC/DC0%0/2
$self ||= "Future"->new
$self
"Future"->new
Truth table66%2/3
A ||= B
A= $selfB= "Future"->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 57 | $self->{subs} = \@flaggedsubs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 57 | $self->on_cancel( \&_cancel_subs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 57 | @$subs = pairkeys @flaggedsubs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 57 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # This might be called by a DESTROY during global destruction so it should | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | # be as defensive as possible (see RT88967) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 41 | ▶ | sub _cancel_subs ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cancel_subs: called CC=6 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 41 | ▶ | my $subs = $self->{subs} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 41 | foreach ( pairs @$subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 72 | my ( $sub, $flags ) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 72 | ▶ | $sub->cancel if !( $flags & SUBFLAG_NO_CANCEL ) and $sub and !$sub->{ready}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not $flags & 1 and $sub and not $sub->{"ready"}
not $flags & 1 and $sub
MC/DC66%2/3
not $flags & 1 and $sub and not $sub->{"ready"}
not $flags & 1
$sub
not $sub->{"ready"}
Truth table75%3/4
not(A) and B and not(C)
A= not $flags & 1B= $subC= not $sub->{"ready"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 14 | ▶ | sub wait_all ( $class, @subs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_all: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 14 | ▶ | unless( @subs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 2 | my $self = $class->done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 2 | $self->{subs} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 12 | my $self = Future->_new_convergent( \@subs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 12 | my $pending = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 12 | ▶ | $_->{ready} or $pending++ for @subs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | # Look for immediate ready | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 12 | ▶ | if( !$pending ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 1 | $self->{result} = [ @subs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 1 | $self->_mark_ready( "wait_all" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 11 | weaken( my $weakself = $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 15 | ▶ | my $sub_on_ready = sub ( $f ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 15 | ▶ | return unless my $self = $weakself; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 15 | $pending--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 15 | ▶ | $pending and return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 10 | $self->{result} = [ pairkeys $self->{subs}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 10 | $self->_mark_ready( "wait_all" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 11 | foreach my $sub ( @subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 19 | ▶ | $sub->{ready} or $sub->on_ready( $sub_on_ready ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 18 | ▶ | sub wait_any ( $class, @subs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_any: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 18 | ▶ | unless( @subs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 2 | my $self = $class->fail( "Cannot ->wait_any with no subfutures" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 2 | $self->{subs} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 16 | my $self = Future->_new_convergent( \@subs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | # Look for immediate ready | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 16 | my $immediate_ready; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 16 | foreach my $sub ( @subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 27 | ▶ | $sub->{ready} and !$sub->{cancelled} and $immediate_ready = $sub, last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$sub->{"ready"} and not $sub->{"cancelled"}
MC/DC100%2/2
$sub->{"ready"} and not $sub->{"cancelled"}
$sub->{"ready"}
not $sub->{"cancelled"}
Truth table100%3/3
A and not(B)
A= $sub->{"ready"}B= not $sub->{"cancelled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 16 | ▶ | if( $immediate_ready ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 2 | $self->_cancel_subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 2 | ▶ | if( $immediate_ready->{failure} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | $self->{failure} = [ $immediate_ready->{failure}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 2 | $self->{result} = [ $immediate_ready->{result}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 2 | $self->_mark_ready( "wait_any" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 14 | my $pending = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 14 | weaken( my $weakself = $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 21 | ▶ | my $sub_on_ready = sub ( $f ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 21 | ▶ | return unless my $self = $weakself; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 21 | ▶ | return if $self->{result} or $self->{failure}; # don't recurse on child ->cancel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"result"} or $self->{"failure"}
MC/DC100%2/2
$self->{"result"} or $self->{"failure"}
$self->{"result"}
$self->{"failure"}
Truth table100%3/3
A or B
A= $self->{"result"}B= $self->{"failure"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 15 | ▶ | return if --$pending and $f->{cancelled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
--$pending and $f->{"cancelled"}
MC/DC100%2/2
--$pending and $f->{"cancelled"}
--$pending
$f->{"cancelled"}
Truth table100%3/3
A and B
A= --$pendingB= $f->{"cancelled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 13 | ▶ | if( $f->{cancelled} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 2 | $self->{failure} = [ "All component futures were cancelled" ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | elsif( $f->{failure} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 3 | $self->{failure} = [ $f->{failure}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 8 | $self->{result} = [ $f->{result}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 13 | $self->_cancel_subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 13 | $self->_mark_ready( "wait_any" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 14 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 14 | foreach my $sub ( @subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | # No need to test $sub->{ready} since we know none of them are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 25 | ▶ | next if $sub->{cancelled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 24 | $sub->on_ready( $sub_on_ready ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 24 | $pending++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 14 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 18 | ▶ | sub needs_all ( $class, @subs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
needs_all: called CC=12 SCAR=24.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 18 | ▶ | unless( @subs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 2 | my $self = $class->done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 2 | $self->{subs} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 16 | my $self = Future->_new_convergent( \@subs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | # Look for immediate fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 16 | my $immediate_failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 16 | foreach my $sub ( @subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 30 | ▶ | $sub->{cancelled} and $immediate_failure = [ "A component future was cancelled" ], last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 29 | ▶ | $sub->{ready} and $sub->{failure} and $immediate_failure = $sub->{failure}, last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$sub->{"ready"} and $sub->{"failure"}
MC/DC100%2/2
$sub->{"ready"} and $sub->{"failure"}
$sub->{"ready"}
$sub->{"failure"}
Truth table100%3/3
A and B
A= $sub->{"ready"}B= $sub->{"failure"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 16 | ▶ | if( $immediate_failure ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 2 | $self->_cancel_subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 2 | $self->{failure} = [ @$immediate_failure ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 2 | $self->_mark_ready( "needs_all" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 14 | my $pending = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 14 | ▶ | $_->{ready} or $pending++ for @subs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | # Look for immediate done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 14 | ▶ | if( !$pending ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 1 | $self->{result} = [ map { $_->{result}->@* } @subs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 1 | $self->_mark_ready( "needs_all" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 13 | weaken( my $weakself = $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 24 | ▶ | my $sub_on_ready = sub ( $f ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 24 | ▶ | return unless my $self = $weakself; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 24 | ▶ | return if $self->{result} or $self->{failure}; # don't recurse on child ->cancel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"result"} or $self->{"failure"}
MC/DC50%1/2
$self->{"result"} or $self->{"failure"}
$self->{"result"}
$self->{"failure"}
Truth table66%2/3
A or B
A= $self->{"result"}B= $self->{"failure"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 19 | ▶ | if( $f->{cancelled} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 4 | $self->{failure} = [ "A component future was cancelled" ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 4 | $self->_cancel_subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 4 | $self->_mark_ready( "needs_all" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | elsif( $f->{failure} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 4 | $self->{failure} = [ $f->{failure}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 4 | $self->_cancel_subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 4 | $self->_mark_ready( "needs_all" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 11 | $pending--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 11 | ▶ | $pending and return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 4 | $self->{result} = [ map { $_->{result}->@* } pairkeys $self->{subs}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 4 | $self->_mark_ready( "needs_all" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 13 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 13 | foreach my $sub ( @subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 26 | ▶ | $sub->{ready} or $sub->on_ready( $sub_on_ready ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 13 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 15 | ▶ | sub needs_any ( $class, @subs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
needs_any: called CC=16 SCAR=27.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 15 | ▶ | unless( @subs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 2 | my $self = $class->fail( "Cannot ->needs_any with no subfutures" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 2 | $self->{subs} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 13 | my $self = Future->_new_convergent( \@subs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | # Look for immediate done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 13 | my $immediate_done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 13 | my $pending = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 13 | foreach my $sub ( @subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 22 | ▶ | $sub->{ready} and !$sub->{failure} and !$sub->{cancelled} and $immediate_done = $sub, last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$sub->{"ready"} and not $sub->{"failure"} and not $sub->{"cancelled"}
$sub->{"ready"} and not $sub->{"failure"}
MC/DC100%3/3
$sub->{"ready"} and not $sub->{"failure"} and not $sub->{"cancelled"}
$sub->{"ready"}
not $sub->{"failure"}
not $sub->{"cancelled"}
Truth table100%4/4
A and not(B) and not(C)
A= $sub->{"ready"}B= not $sub->{"failure"}C= not $sub->{"cancelled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 21 | ▶ | $sub->{ready} or $pending++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 13 | ▶ | if( $immediate_done ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 1 | foreach my $sub ( @subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 2 | ▶ | $sub->{ready} ? $sub->{reported} = 1 : $sub->cancel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 1 | $self->{result} = [ $immediate_done->{result}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 1 | $self->_mark_ready( "needs_any" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | # Look for immediate fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 12 | my $immediate_fail = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 12 | foreach my $sub ( @subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 12 | ▶ | $sub->{ready} or $immediate_fail = 0, last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 12 | ▶ | if( $immediate_fail ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 1 | $_->{reported} = 1 for @subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | # For consistency we'll pick the last one for the failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 1 | $self->{failure} = [ $subs[-1]->{failure}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 1 | $self->_mark_ready( "needs_any" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 11 | weaken( my $weakself = $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 16 | ▶ | my $sub_on_ready = sub ( $f ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 16 | ▶ | return unless my $self = $weakself; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 16 | ▶ | return if $self->{result} or $self->{failure}; # don't recurse on child ->cancel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"result"} or $self->{"failure"}
MC/DC50%1/2
$self->{"result"} or $self->{"failure"}
$self->{"result"}
$self->{"failure"}
Truth table66%2/3
A or B
A= $self->{"result"}B= $self->{"failure"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 14 | ▶ | return if --$pending and $f->{cancelled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
--$pending and $f->{"cancelled"}
MC/DC100%2/2
--$pending and $f->{"cancelled"}
--$pending
$f->{"cancelled"}
Truth table100%3/3
A and B
A= --$pendingB= $f->{"cancelled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 12 | ▶ | if( $f->{cancelled} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 2 | $self->{failure} = [ "All component futures were cancelled" ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 2 | $self->_mark_ready( "needs_any" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | elsif( $f->{failure} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 3 | ▶ | $pending and return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 1 | $self->{failure} = [ $f->{failure}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 1 | $self->_mark_ready( "needs_any" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 7 | $self->{result} = [ $f->{result}->@* ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 7 | $self->_cancel_subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 7 | $self->_mark_ready( "needs_any" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 11 | foreach my $sub ( @subs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 19 | ▶ | $sub->{ready} or $sub->on_ready( $sub_on_ready ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 7 | ▶ | sub pending_futures ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending_futures: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 7 | ▶ | $self->{subs} or Carp::croak "Cannot call ->pending_futures on a non-convergent Future"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 7 | return grep { not $_->{ready} } pairkeys $self->{subs}->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 7 | ▶ | sub ready_futures ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ready_futures: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 7 | ▶ | $self->{subs} or Carp::croak "Cannot call ->ready_futures on a non-convergent Future"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 7 | return grep { $_->{ready} } pairkeys $self->{subs}->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 9 | ▶ | sub done_futures ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
done_futures: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 9 | ▶ | $self->{subs} or Carp::croak "Cannot call ->done_futures on a non-convergent Future"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 9 | ▶ | return grep { $_->{ready} and not $_->{failure} and not $_->{cancelled} } pairkeys $self->{subs}->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$_->{'ready'} && !$_->{'failure'} && !$_->{'cancelled'}
$_->{"ready"} and not $_->{"failure"}
MC/DC100%3/3
$_->{'ready'} && !$_->{'failure'} && !$_->{'cancelled'}
$_->{"ready"}
not $_->{"failure"}
!$_->{'cancelled'}
Truth table100%4/4
A and not(B) && not(C)
A= $_->{"ready"}B= not $_->{"failure"}C= !$_->{'cancelled'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 4 | ▶ | sub failed_futures ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
failed_futures: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 4 | ▶ | $self->{subs} or Carp::croak "Cannot call ->failed_futures on a non-convergent Future"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 4 | ▶ | return grep { $_->{ready} and $_->{failure} } pairkeys $self->{subs}->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_->{'ready'} && $_->{'failure'}
MC/DC50%1/2
$_->{'ready'} && $_->{'failure'}
$_->{'ready'}
$_->{'failure'}
Truth table66%2/3
A && B
A= $_->{'ready'}B= $_->{'failure'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 6 | ▶ | sub cancelled_futures ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cancelled_futures: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 6 | ▶ | $self->{subs} or Carp::croak "Cannot call ->cancelled_futures on a non-convergent Future"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 6 | ▶ | return grep { $_->{ready} and $_->{cancelled} } pairkeys $self->{subs}->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_->{'ready'} && $_->{'cancelled'}
MC/DC50%1/2
$_->{'ready'} && $_->{'cancelled'}
$_->{'ready'}
$_->{'cancelled'}
Truth table66%2/3
A && B
A= $_->{'ready'}B= $_->{'cancelled'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 11 | ▶ | sub btime ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
btime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 11 | return $self->{btime}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 12 | ▶ | sub rtime ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rtime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 12 | return $self->{rtime}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 6 | ▶ | sub set_label ( $self, $label ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_label: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 6 | $self->{label} = $label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 1 | ▶ | sub label ( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 1 | return $self->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 1 | ▶ | sub set_udata ( $self, $name, $value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_udata: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 1 | $self->{"u_$name"} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 1 | ▶ | sub udata ( $self, $name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
udata: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 1 | return $self->{"u_$name"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 33 | 0x55AA; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||