| 1 | package Object::Remote::MiniLoop; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 26 | ▶ | use IO::Select; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 26 | ▶ | use Time::HiRes qw(time); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 26 | ▶ | use Object::Remote::Logging qw( :log :dlog router ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 13 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 13 | router()->exclude_forwarding | |||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # this is ro because we only actually set it using local in sub run | ||||||||||||||||||||||||||||
| 13 | has is_running => (is => 'ro', clearer => 'stop'); | ||||||||||||||||||||||||||||
| 14 | #maximum duration that select() will block - undef means indefinite, | ||||||||||||||||||||||||||||
| 15 | #0 means no blocking, otherwise maximum time in seconds | ||||||||||||||||||||||||||||
| 16 | has block_duration => ( is => 'rw' ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 13 | ▶ | has _read_watches => (is => 'ro', default => sub { {} }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 13 | ▶ | has _read_select => (is => 'ro', default => sub { IO::Select->new }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 13 | ▶ | has _write_watches => (is => 'ro', default => sub { {} }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 13 | ▶ | has _write_select => (is => 'ro', default => sub { IO::Select->new }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 13 | ▶ | has _timers => (is => 'ro', default => sub { [] }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 40 | ▶ | sub watch_io { | ||||||||||||||||||||||||||
|
Subroutine
watch_io: called CC=3 SCAR=14.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my ($self, %watch) = @_; | ||||||||||||||||||||||||||
|
Subroutine
watch_io: not called CC=3 SCAR=14.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 0 | my $fh = $watch{handle}; | |||||||||||||||||||||||||||
| 29 | 0 | ▶ | Dlog_debug { "Adding IO watch for $_" } $fh; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if (my $cb = $watch{on_read_ready}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | log_trace { "IO watcher is registering with select for reading" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 33 | 0 | $self->_read_select->add($fh); | |||||||||||||||||||||||||||
| 34 | 0 | $self->_read_watches->{$fh} = $cb; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if (my $cb = $watch{on_write_ready}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | log_trace { "IO watcher is registering with select for writing" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 38 | 0 | $self->_write_select->add($fh); | |||||||||||||||||||||||||||
| 39 | 0 | $self->_write_watches->{$fh} = $cb; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 0 | return; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub unwatch_io { | ||||||||||||||||||||||||||||
| 45 | 21 | ▶ | my ($self, %watch) = @_; | ||||||||||||||||||||||||||
|
Subroutine
unwatch_io: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 21 | my $fh = $watch{handle}; | |||||||||||||||||||||||||||
| 47 | 21 | ▶ | Dlog_debug { "Removing IO watch for $_" } $fh; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 48 | 21 | ▶ | if ($watch{on_read_ready}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 2 | ▶ | log_trace { "IO watcher is removing read from select()" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 50 | 2 | $self->_read_select->remove($fh); | |||||||||||||||||||||||||||
| 51 | 2 | delete $self->_read_watches->{$fh}; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 21 | ▶ | if ($watch{on_write_ready}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 19 | ▶ | log_trace { "IO watcher is removing write from select()" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 55 | 19 | $self->_write_select->remove($fh); | |||||||||||||||||||||||||||
| 56 | 19 | delete $self->_write_watches->{$fh}; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 21 | return; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | sub _sort_timers { | ||||||||||||||||||||||||||||
| 62 | 26 | ▶ | my ($self, @new) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_sort_timers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 26 | my $timers = $self->_timers; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 26 | ▶ | log_trace { "Sorting timers" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 26 | @{$timers} = sort { $a->[0] <=> $b->[0] } @{$timers}, @new; | |||||||||||||||||||||||||||
| 68 | 26 | return; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub watch_time { | ||||||||||||||||||||||||||||
| 72 | 26 | ▶ | my ($self, %watch) = @_; | ||||||||||||||||||||||||||
|
Subroutine
watch_time: called CC=4 SCAR=15.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 26 | my $at; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 26 | ▶ | Dlog_trace { "watch_time() invoked with $_" } \%watch; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 26 | ▶ | if (exists($watch{after})) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 78 | 26 | $at = time() + $watch{after}; | |||||||||||||||||||||||||||
| 79 | } elsif (exists($watch{at})) { | ||||||||||||||||||||||||||||
| 80 | 0 | $at = $watch{at}; | |||||||||||||||||||||||||||
| 81 | } else { | ||||||||||||||||||||||||||||
| 82 | 0 | die "watch_time requires after or at"; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 26 | ▶ | die "watch_time requires code" unless my $code = $watch{code}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 26 | my $timers = $self->_timers; | |||||||||||||||||||||||||||
| 87 | 26 | my $new = [ $at => $code ]; | |||||||||||||||||||||||||||
| 88 | 26 | $self->_sort_timers($new); | |||||||||||||||||||||||||||
| 89 | 26 | ▶ | log_debug { "Created new timer with id '$new' that expires at '$at'" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 90 | 26 | return "$new"; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | sub unwatch_time { | ||||||||||||||||||||||||||||
| 94 | 1 | ▶ | my ($self, $id) = @_; | ||||||||||||||||||||||||||
|
Subroutine
unwatch_time: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 1 | ▶ | log_trace { "Removing timer with id of '$id'" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 96 | 1 | @$_ = grep !($_ eq $id), @$_ for $self->_timers; | |||||||||||||||||||||||||||
| 97 | 1 | return; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | sub _next_timer_expires_delay { | ||||||||||||||||||||||||||||
| 101 | 1203 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_next_timer_expires_delay: called CC=5 SCAR=18.9
| |||||||||||||||||||||||||||||
| 102 | 1203 | my $timers = $self->_timers; | |||||||||||||||||||||||||||
| 103 | 1203 | my $delay_max = $self->block_duration; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 1203 | ▶ | return $delay_max unless @$timers; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 1203 | my $duration = $timers->[0]->[0] - time; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1203 | ▶ | log_trace { "next timer fires in '$duration' seconds" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 1203 | ▶ | if ($duration < 0) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 111 | 0 | $duration = 0; | |||||||||||||||||||||||||||
| 112 | ▶ | } elsif (defined $delay_max && $duration > $delay_max) { | |||||||||||||||||||||||||||
|
Condition33%1/3
defined $delay_max and $duration > $delay_max
MC/DC0%0/2
defined $delay_max and $duration > $delay_max
defined $delay_max
$duration > $delay_max
Truth table33%1/3
A and B
A= defined $delay_maxB= $duration > $delay_max
| |||||||||||||||||||||||||||||
| 113 | 0 | $duration = $delay_max; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 1203 | return $duration; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | sub loop_once { | ||||||||||||||||||||||||||||
| 120 | 1203 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
loop_once: called CC=7 SCAR=21.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 121 | 1203 | my $read = $self->_read_watches; | |||||||||||||||||||||||||||
| 122 | 1203 | my $write = $self->_write_watches; | |||||||||||||||||||||||||||
| 123 | 1203 | my $read_count = 0; | |||||||||||||||||||||||||||
| 124 | 1203 | my $write_count = 0; | |||||||||||||||||||||||||||
| 125 | 1203 | my @c = caller; | |||||||||||||||||||||||||||
| 126 | 1203 | my $wait_time = $self->_next_timer_expires_delay; | |||||||||||||||||||||||||||
| 127 | log_trace { | ||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sprintf("Run loop: loop_once() has been invoked by $c[1]:$c[2] with read:%i write:%i select timeout:%s", | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | scalar(keys(%$read)), scalar(keys(%$write)), defined $wait_time ? $wait_time : 'indefinite' ) | ||||||||||||||||||||||||||||
| 130 | 1203 | }; | |||||||||||||||||||||||||||
| 131 | 1203 | my ($readable, $writeable) = IO::Select->select( | |||||||||||||||||||||||||||
| 132 | $self->_read_select, $self->_write_select, undef, $wait_time | ||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||
| 134 | log_trace { | ||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my $readable_count = defined $readable ? scalar(@$readable) : 0; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 0 | ▶ | my $writable_count = defined $writeable ? scalar(@$writeable) : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | "Run loop: select returned readable:$readable_count writeable:$writable_count"; | |||||||||||||||||||||||||||
| 138 | 1203 | }; | |||||||||||||||||||||||||||
| 139 | # I would love to trap errors in the select call but IO::Select doesn't | ||||||||||||||||||||||||||||
| 140 | # differentiate between an error and a timeout. | ||||||||||||||||||||||||||||
| 141 | # -- no, love, mst. | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 1203 | ▶ | log_trace { "Reading from ready filehandles" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 144 | 1203 | foreach my $fh (@$readable) { | |||||||||||||||||||||||||||
| 145 | 188 | ▶ | next unless $read->{$fh}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 188 | $read_count++; | |||||||||||||||||||||||||||
| 147 | 188 | $read->{$fh}(); | |||||||||||||||||||||||||||
| 148 | #FIXME this is a rough workaround for race conditions that can cause deadlocks | ||||||||||||||||||||||||||||
| 149 | #under load | ||||||||||||||||||||||||||||
| 150 | 188 | last; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | 1203 | ▶ | log_trace { "Writing to ready filehandles" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 153 | 1203 | foreach my $fh (@$writeable) { | |||||||||||||||||||||||||||
| 154 | 1009 | ▶ | next unless $write->{$fh}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 1009 | $write_count++; | |||||||||||||||||||||||||||
| 156 | 1009 | $write->{$fh}(); | |||||||||||||||||||||||||||
| 157 | #FIXME this is a rough workaround for race conditions that can cause deadlocks | ||||||||||||||||||||||||||||
| 158 | #under load | ||||||||||||||||||||||||||||
| 159 | 1009 | last; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | #moving the timers above the read() section exposes a deadlock | ||||||||||||||||||||||||||||
| 163 | 1203 | ▶ | log_trace { "Read from $read_count filehandles; wrote to $write_count filehandles" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 164 | 1203 | my $timers = $self->_timers; | |||||||||||||||||||||||||||
| 165 | 1203 | my $now = time(); | |||||||||||||||||||||||||||
| 166 | 1203 | ▶ | log_trace { "Checking timers" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 167 | 1203 | ▶ | while (@$timers and $timers->[0][0] <= $now) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$timers and $timers->[0][0] <= $now
MC/DC100%2/2
@$timers and $timers->[0][0] <= $now
@$timers
$timers->[0][0] <= $now
Truth table100%3/3
A and B
A= @$timersB= $timers->[0][0] <= $now
| |||||||||||||||||||||||||||||
| 168 | 6 | my $active = $timers->[0]; | |||||||||||||||||||||||||||
| 169 | 6 | ▶ | Dlog_trace { "Found timer that needs to be executed: '$active'" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 170 | 6 | shift(@$timers); | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | #execute the timer | ||||||||||||||||||||||||||||
| 173 | 6 | $active->[1]->(); | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 1203 | ▶ | log_trace { "Run loop: single loop is completed" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 177 | 1203 | return; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | sub run { | ||||||||||||||||||||||||||||
| 181 | 170 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 182 | 170 | ▶ | log_trace { "Run loop: run() invoked" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 183 | 170 | local $self->{is_running} = 1; | |||||||||||||||||||||||||||
| 184 | 170 | ▶ | while ($self->is_running) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 1203 | $self->loop_once; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | 170 | ▶ | log_trace { "Run loop: run() completed" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 188 | 170 | return; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | sub new_future { | ||||||||||||||||||||||||||||
| 192 | 303 | ▶ | return Future->new; | ||||||||||||||||||||||||||
|
Subroutine
new_future: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | our @await; | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | sub await { | ||||||||||||||||||||||||||||
| 198 | 170 | ▶ | my ($self, $f) = @_; | ||||||||||||||||||||||||||
|
Subroutine
await: called CC=4 SCAR=14.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 199 | 170 | ▶ | log_trace { my $ir = $f->is_ready; "await_future() invoked; is_ready: $ir" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 200 | 170 | ▶ | return $f if $f->is_ready; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | 170 | require Object::Remote; | |||||||||||||||||||||||||||
| 202 | 170 | my $loop = Object::Remote->current_loop; | |||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||
| 204 | 170 | local @await = (@await, $f); | |||||||||||||||||||||||||||
| 205 | $f->on_ready(sub { | ||||||||||||||||||||||||||||
| 206 | 170 | ▶ | log_trace { my $l = @await; "future has become ready, length of \@await: '$l'" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 207 | 170 | ▶ | if ($f == $await[-1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 170 | ▶ | log_trace { "This future is not waiting on anything so calling stop on the run loop" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 209 | 170 | $loop->stop; | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | 170 | }); | |||||||||||||||||||||||||||
| 212 | 170 | ▶ | log_trace { "Starting run loop for newly created future" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 213 | 170 | $loop->run; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | 170 | ▶ | if (@await and $await[-1]->is_ready) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@Object::Remote::MiniLoop::await and $Object::Remote::MiniLoop::await[-1]->is_ready
MC/DC50%1/2
@Object::Remote::MiniLoop::await and $Object::Remote::MiniLoop::await[-1]->is_ready
@Object::Remote::MiniLoop::await
$Object::Remote::MiniLoop::await[-1]->is_ready
Truth table66%2/3
A and B
A= @Object::Remote::MiniLoop::awaitB= $Object::Remote::MiniLoop::await[-1]->is_ready
| |||||||||||||||||||||||||||||
| 216 | 57 | ▶ | log_trace { "Last future in await list was ready, stopping run loop" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 217 | 57 | $loop->stop; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | 170 | ▶ | log_trace { "await_future() returning" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 220 | 170 | return $f; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | sub await_all { | ||||||||||||||||||||||||||||
| 224 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
await_all: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 225 | 2 | $self->await(Future->wait_all(@_)); | |||||||||||||||||||||||||||
| 226 | 2 | return; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 1; | ||||||||||||||||||||||||||||