blib/lib/Zuzu/Runtime/Async/TaskGroup.pm

filter: Statementstmt 80.0% 28 / 35 Branchbran 41.6% 5 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 4 totaltotal 68.3% 41 / 60 CC 8 SCAR 18.6
CC
8
Cov
70%
cancel
20.0
add
3.1
remove
2.0
CRAP 6.4
« blib/lib/Zuzu/Web/PSGI.pm ↑ Summary blib/lib/Zuzu/Marshal/CBOR.pm »
1 package Zuzu::Runtime::Async::TaskGroup;
2  
3 69 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 69 our $VERSION = '0.007002';
6  
7 69 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 69 ▶use Scalar::Util qw( refaddr weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 69 has 'parent' => ( is => 'rw' );
11 562 ▶has 'tasks' => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
12 562 ▶has 'cancelled' => ( is => 'rw', default => sub { 0 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
13 69 has 'reason' => ( is => 'rw' );
14  
15 562 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
16 562 my ( $self ) = @_;
17  
18 562 ▶ weaken( $self->{parent} ) if defined $self->{parent};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"parent"} 15 547 562
19 }
20  
21 159 ▶sub add {
Subroutine add: called CC=3 SCAR=11.3
Pod undocumented
22 159 my ( $self, $task ) = @_;
23  
24 159 ▶ return $task if !defined $task;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $task 0 159 159
25 159 $self->tasks->{ refaddr($task) } = $task;
26 159 ▶ $task->group($self) if $task->can('group');
Branch: 1 branch
BranchTrueFalseTotal
if $task->can("group") 159 0 159
27  
28 159 return $task;
29 }
30  
31 454 ▶sub remove {
Subroutine remove: called CC=2 SCAR=7.0
Pod undocumented
32 454 my ( $self, $task ) = @_;
33  
34 454 ▶ return if !defined $task;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $task 0 454 454
35 454 delete $self->tasks->{ refaddr($task) };
36  
37 454 return;
38 }
39  
40 0 ▶sub cancel {
Subroutine cancel: not called CC=4 SCAR=30.0
Pod undocumented
41 0 my ( $self, $reason ) = @_;
42  
43 0 $self->cancelled(1);
44 0 ▶ $self->reason($reason) if defined $reason;
Branch: 1 branch
BranchTrueFalseTotal
if defined $reason 0 0 0
45 0 for my $task ( values %{ $self->tasks } ) {
46 0 ▶ $task->cancel($reason) if $task->can('cancel');
Branch: 1 branch
BranchTrueFalseTotal
if $task->can("cancel") 0 0 0
47 }
48  
49 0 return $self;
50 }
51  
52 69 1;
53  
54 =pod
55  
56 =head1 COPYRIGHT AND LICENCE
57  
58 B<< Zuzu::Runtime::Async::TaskGroup >> is copyright Toby Inkster.
59  
60 It is free software; you may redistribute it and/or modify it under
61 the terms of either the Artistic License 1.0 or the GNU General Public
62 License version 2.
63  
64 =cut
« blib/lib/Zuzu/Web/PSGI.pm ↑ Summary blib/lib/Zuzu/Marshal/CBOR.pm »