| 1 | package Mojo::UserAgent::Role::Queued::Queue; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Mojo::Base 'Mojo::EventEmitter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | has jobs => sub { [] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | has active => 0; | |||||||||||||||||||||||||||
| 10 | 4 | has max_active => 4; | |||||||||||||||||||||||||||
| 11 | 4 | has callback => undef; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 30 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 30 | my ($self) = @_; | |||||||||||||||||||||||||||
| 16 | # we have jobs and can run them: | ||||||||||||||||||||||||||||
| 17 | 30 | ▶ | while ($self->active < $self->max_active | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->active < $self->max_active and my $job = shift @{$self->jobs;}
MC/DC100%2/2
$self->active < $self->max_active and my $job = shift @{$self->jobs;}
$self->active < $self->max_active
my $job = shift @{$self->jobs;}
Truth table100%3/3
A and B
A= $self->active < $self->max_activeB= my $job = shift @{$self->jobs;}
| |||||||||||||||||||||||||||||
| 18 | 36 | and my $job = shift @{$self->jobs}) | |||||||||||||||||||||||||||
| 19 | { | ||||||||||||||||||||||||||||
| 20 | 15 | $self->active($self->active + 1); | |||||||||||||||||||||||||||
| 21 | 15 | my $tx = shift @$job; | |||||||||||||||||||||||||||
| 22 | 15 | my $cb = shift @$job; | |||||||||||||||||||||||||||
| 23 | 15 | weaken $self; | |||||||||||||||||||||||||||
| 24 | 15 | ▶ | $tx->on(finish => sub { $self->tx_finish(); }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 15 | $self->callback->( $tx, $cb ); | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | 30 | ▶ | if (scalar @{$self->jobs} == 0 && $self->active == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
scalar @{$self->jobs;} == 0 and $self->active == 0
MC/DC100%2/2
scalar @{$self->jobs;} == 0 and $self->active == 0
scalar @{$self->jobs;} == 0
$self->active == 0
Truth table100%3/3
A and B
A= scalar @{$self->jobs;} == 0B= $self->active == 0
| |||||||||||||||||||||||||||||
| 28 | 6 | $self->emit('queue_empty'); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 15 | ▶ | sub tx_finish { | ||||||||||||||||||||||||||
|
Subroutine
tx_finish: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||
| 34 | 15 | $self->active($self->active - 1); | |||||||||||||||||||||||||||
| 35 | 15 | $self->process(); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 15 | ▶ | sub enqueue { | ||||||||||||||||||||||||||
|
Subroutine
enqueue: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 15 | my ($self, $tx, $cb) = @_; | |||||||||||||||||||||||||||
| 40 | 15 | my $job = [$tx, $cb]; | |||||||||||||||||||||||||||
| 41 | 15 | push @{$self->jobs}, $job; | |||||||||||||||||||||||||||
| 42 | 15 | $self->process(); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 4 | 1; | |||||||||||||||||||||||||||