| 1 | package Ryu::Node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 46 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 46 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 46 | our $VERSION = '4.001'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 46 | our $AUTHORITY = 'cpan:TEAM'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | Ryu::Node - generic node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | This is a common base class for all sources, sinks and other related things. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | It does very little. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 46 | ▶ | use Future; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 46 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | Not really. There's a constructor, but that's not particularly exciting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 237 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 237 | bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | pause_propagation => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | @_[1..$#_] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | }, $_[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | =head2 describe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | Returns a string describing this node and any parents - typically this will result in a chain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | like C<< from->combine_latest->count >>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # It'd be nice if L<Future> already provided a method for this, maybe I should suggest it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1184 | ▶ | sub describe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1184 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1184 | my $completed = $self->_completed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1184 | ▶ | ($self->parent ? $self->parent->describe . '=>' : '') . '[' . ($self->label // 'unknown') . '](' . ($completed ? $completed->state : 'inactive') . ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%2/2
$self->label // "unknown"
MC/DC100%1/1
$self->label // "unknown"
$self->label
Truth table100%2/2
A
A= $self->label
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | =head2 completed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | Returns a L<Future> indicating completion (or failure) of this stream. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 42 | ▶ | sub completed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
completed: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 42 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 42 | ▶ | my $completion = $self->_completed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 39 | ▶ | return $completion->without_cancel->on_ready(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 39 | my $f = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 39 | my ($expected) = $f->state =~ /^(\S+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 39 | my ($actual) = $completion->state =~ /^(\S+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 39 | ▶ | if($expected ne $actual) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | warn "Completed state $actual does not match internal state $expected - if you are calling ->completed->$expected, this will not work: use ->finish or ->fail instead"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 42 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # Internal use only, since it's cancellable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3285 | ▶ | sub _completed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_completed: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 3285 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 3285 | ▶ | return $self->{completed} if $self->{completed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 223 | $self->{completed} = my $f = $self->new_future( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 'completion' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 223 | ▶ | $f->on_ready( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | $self->curry::weak::cleanup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ) if $self->can('cleanup'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 223 | $f | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | =head2 pause | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | Does nothing useful. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 55 | ▶ | sub pause { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pause: called CC=13 SCAR=26.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 55 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 55 | ▶ | my $k = (defined $src and ref $src) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition70%7/10
defined $src and ref $src
builtin::refaddr($src // $self) // 0
$src // $self
$src // 0
MC/DC100%2/2
defined $src and ref $src
defined $src
ref $src
MC/DC0%0/2
builtin::refaddr($src // $self) // 0
$src
$self
MC/DC100%1/1
$src // 0
$src
Truth table100%3/3
A and B
A= defined $srcB= ref $src
Truth table33%1/3
A // B
A= $srcB= $self
Truth table100%2/2
A
A= $src
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ? refaddr($src // $self) // 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | : $src // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 55 | ▶ | my $was_paused = $self->{is_paused} && keys %{$self->{is_paused}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'is_paused'} && keys %{$$self{'is_paused'};}
MC/DC0%0/2
$self->{'is_paused'} && keys %{$$self{'is_paused'};}
$self->{'is_paused'}
keys %{$$self{'is_paused'};}
Truth table66%2/3
A && B
A= $self->{'is_paused'}B= keys %{$$self{'is_paused'};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 55 | ▶ | if($self->{unblocked} and $self->{unblocked}->is_ready) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"unblocked"} and $self->{"unblocked"}->is_ready
MC/DC50%1/2
$self->{"unblocked"} and $self->{"unblocked"}->is_ready
$self->{"unblocked"}
$self->{"unblocked"}->is_ready
Truth table66%2/3
A and B
A= $self->{"unblocked"}B= $self->{"unblocked"}->is_ready
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | delete $self->{unblocked}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 55 | ++$self->{is_paused}{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 55 | ▶ | if(my $parent = $self->parent) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 37 | ▶ | $parent->pause($self) if $self->{pause_propagation}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 55 | ▶ | if(my $flow_control = $self->{flow_control}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 21 | ▶ | $flow_control->emit(0) unless $was_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 55 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | =head2 resume | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | Is about as much use as L</pause>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 59 | ▶ | sub resume { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume: called CC=14 SCAR=27.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 59 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 59 | ▶ | my $k = (defined $src and ref $src) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition70%7/10
defined $src and ref $src
builtin::refaddr($src // $self) // 0
$src // $self
$src // 0
MC/DC100%2/2
defined $src and ref $src
defined $src
ref $src
MC/DC0%0/2
builtin::refaddr($src // $self) // 0
$src
$self
MC/DC100%1/1
$src // 0
$src
Truth table100%3/3
A and B
A= defined $srcB= ref $src
Truth table33%1/3
A // B
A= $srcB= $self
Truth table100%2/2
A
A= $src
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ? refaddr($src // $self) // 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | : $src // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 59 | ▶ | delete $self->{is_paused}{$k} unless --$self->{is_paused}{$k} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 59 | ▶ | return $self if $self->{is_paused} and keys %{$self->{is_paused}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"is_paused"} and keys %{$$self{"is_paused"};}
MC/DC0%0/2
$self->{"is_paused"} and keys %{$$self{"is_paused"};}
$self->{"is_paused"}
keys %{$$self{"is_paused"};}
Truth table33%1/3
A and B
A= $self->{"is_paused"}B= keys %{$$self{"is_paused"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 59 | ▶ | if(my $f = $self->{unblocked}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | $f->done unless $f->is_ready; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 59 | ▶ | if(my $parent = $self->parent) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 39 | ▶ | $parent->resume($self) if $self->{pause_propagation}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 59 | ▶ | if(my $flow_control = $self->{flow_control}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 21 | $flow_control->emit(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 59 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | =head2 unblocked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | Returns a L<Future> representing the current flow control state of this node. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | It will be L<pending|Future/is_pending> if this node is currently paused, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | otherwise L<ready|Future/is_ready>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 6 | ▶ | sub unblocked { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unblocked: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # Since we don't want stray callers to affect our internal state, we always return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # a non-cancellable version of our internal Future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 6 | return $self->_unblocked->without_cancel | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 6 | ▶ | sub _unblocked { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unblocked: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # Since we don't want stray callers to affect our internal state, we always return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # a non-cancellable version of our internal Future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 6 | ▶ | $self->{unblocked} //= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"unblocked"} //= do {
$self->is_paused ? $self->new_future : "Future"->done
}
MC/DC0%0/2
$self->{"unblocked"} //= do {
$self->is_paused ? $self->new_future : "Future"->done
}
$self->{"unblocked"}
do {
$self->is_paused ? $self->new_future : "Future"->done
}
Truth table33%1/3
A //= B
A= $self->{"unblocked"}B= do {
$self->is_paused ? $self->new_future : "Future"->done
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 6 | ▶ | $self->is_paused | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ? $self->new_future | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | : Future->done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | =head2 is_paused | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | Might return 1 or 0, but is generally meaningless. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 274 | ▶ | sub is_paused { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_paused: called CC=9 SCAR=25.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 274 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 274 | ▶ | return keys(%{ $self->{is_paused} }) ? 1 : 0 unless defined $src; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 138 | ▶ | my $k = (defined $src and ref $src) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition30%3/10
defined $src and ref $src
builtin::refaddr($src // $self) // 0
$src // $self
$src // 0
MC/DC0%0/2
defined $src and ref $src
defined $src
ref $src
MC/DC0%0/2
builtin::refaddr($src // $self) // 0
$src
$self
MC/DC0%0/1
$src // 0
$src
Truth table33%1/3
A and B
A= defined $srcB= ref $src
Truth table33%1/3
A // B
A= $srcB= $self
Truth table0%0/2
A
A= $src
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ? refaddr($src // $self) // 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | : $src // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | return exists $self->{is_paused}{$k} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 138 | ▶ | ? 0 + $self->{is_paused}{$k} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 31 | ▶ | sub flow_control { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flow_control: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 31 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 31 | ▶ | return $self->{flow_control} if $self->{flow_control}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | $self->{flow_control} = my $fc = Ryu::Source->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | new_future => $self->{new_future} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 31 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 29 | ▶ | $self->_completed->on_ready(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | my $fc = delete $self->{flow_control} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 29 | ▶ | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 29 | $fc->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 31 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 31 | $fc | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1378 | ▶ | sub label { shift->{label} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2040 | ▶ | sub parent { shift->{parent} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | =head2 new_future | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | Used internally to get a L<Future>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 228 | ▶ | sub new_future { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_future: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 228 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 228 | ▶ | $self->{new_future} //= $Ryu::Source::FUTURE_FACTORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"new_future"} //= $Ryu::Source::FUTURE_FACTORY
MC/DC0%0/2
$self->{"new_future"} //= $Ryu::Source::FUTURE_FACTORY
$self->{"new_future"}
$Ryu::Source::FUTURE_FACTORY
Truth table66%2/3
A //= B
A= $self->{"new_future"}B= $Ryu::Source::FUTURE_FACTORY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | )->($self, @_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 46 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||