KiokuDB/GC/Naive.pm

filter: Statementstmt 100% 30 / 30 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 38 / 38 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« KiokuDB/Error.pm ↑ Summary KiokuDB/LinkChecker/Results.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::GC::Naive;
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use KiokuDB::GC::Naive::Mark;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use KiokuDB::GC::Naive::Sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 with qw(KiokuDB::Role::Verbosity);
12  
13 1 has backend => (
14 does => "KiokuDB::Backend::Role::Scan",
15 is => "ro",
16 required => 1,
17 );
18  
19 1 has [qw(mark_scan sweep_scan)] => (
20 is => "ro",
21 lazy_build => 1,
22 );
23  
24 sub _build_mark_scan {
25 9 ▶ my $self = shift;
Subroutine _build_mark_scan: called CC=1 SCAR=0.0
26  
27 9 KiokuDB::GC::Naive::Mark->new(
28 backend => $self->backend,
29 verbose => $self->verbose,
30 );
31 }
32  
33 sub _build_sweep_scan {
34 9 ▶ my $self = shift;
Subroutine _build_sweep_scan: called CC=1 SCAR=0.0
35  
36 9 my $mark_results = $self->mark_results;
37  
38 9 $self->v("sweeping...\n");
39  
40 9 KiokuDB::GC::Naive::Sweep->new(
41 backend => $self->backend,
42 verbose => $self->verbose,
43 mark_results => $mark_results,
44 );
45 }
46  
47 1 has mark_results => (
48 isa => "KiokuDB::GC::Naive::Mark::Results",
49 is => "ro",
50 handles => qr/.*/,
51 lazy_build => 1,
52 );
53  
54 sub _build_mark_results {
55 9 ▶ my $self = shift;
Subroutine _build_mark_results: called CC=1 SCAR=0.0
56  
57 9 $self->v("marking reachable objects...\n");
58  
59 9 return $self->mark_scan->results;
60 }
61  
62 1 has sweep_results => (
63 isa => "KiokuDB::GC::Naive::Sweep::Results",
64 is => "ro",
65 handles => qr/.*/,
66 lazy_build => 1,
67 );
68  
69 sub _build_sweep_results {
70 9 ▶ my $self = shift;
Subroutine _build_sweep_results: called CC=1 SCAR=0.0
71  
72 9 return $self->sweep_scan->results;
73 }
74  
75 1 __PACKAGE__->meta->make_immutable;
76  
77 1 __PACKAGE__
78  
79 __END__
80  
81 =pod
82  
83 =head1 NAME
84  
85 KiokuDB::GC::Naive - Naive mark and sweep garbage collection
86  
87 =head1 SYNOPSIS
88  
89 use KiokuDB::GC::Naive;
90  
91 my $gc = KiokuDB::GC::Naive->new(
92 backend => $backend,
93 );
94  
95 $backend->delete( $gc->garbage->members );
96  
97 =head1 DESCRIPTION
98  
99 This class implements full mark and sweep garbage collection for a backend
100 supporting L<KiokuDB::Backend::Role::Scan>.
101  
102 =cut
103  
104  
« KiokuDB/Error.pm ↑ Summary KiokuDB/LinkChecker/Results.pm »