line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package KiokuDB::GC::Naive; |
4
|
1
|
|
|
1
|
|
16848
|
use Moose; |
|
1
|
|
|
|
|
371607
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6309
|
use KiokuDB::GC::Naive::Mark; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
7
|
1
|
|
|
1
|
|
471
|
use KiokuDB::GC::Naive::Sweep; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
8
|
use namespace::clean -except => 'meta'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with qw(KiokuDB::Role::Verbosity); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has backend => ( |
14
|
|
|
|
|
|
|
does => "KiokuDB::Backend::Role::Scan", |
15
|
|
|
|
|
|
|
is => "ro", |
16
|
|
|
|
|
|
|
required => 1, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has [qw(mark_scan sweep_scan)] => ( |
20
|
|
|
|
|
|
|
is => "ro", |
21
|
|
|
|
|
|
|
lazy_build => 1, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _build_mark_scan { |
25
|
9
|
|
|
9
|
|
14
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
9
|
|
|
|
|
205
|
KiokuDB::GC::Naive::Mark->new( |
28
|
|
|
|
|
|
|
backend => $self->backend, |
29
|
|
|
|
|
|
|
verbose => $self->verbose, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _build_sweep_scan { |
34
|
9
|
|
|
9
|
|
14
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
9
|
|
|
|
|
206
|
my $mark_results = $self->mark_results; |
37
|
|
|
|
|
|
|
|
38
|
9
|
|
|
|
|
27
|
$self->v("sweeping...\n"); |
39
|
|
|
|
|
|
|
|
40
|
9
|
|
|
|
|
224
|
KiokuDB::GC::Naive::Sweep->new( |
41
|
|
|
|
|
|
|
backend => $self->backend, |
42
|
|
|
|
|
|
|
verbose => $self->verbose, |
43
|
|
|
|
|
|
|
mark_results => $mark_results, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
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
|
|
|
9
|
|
12
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
9
|
|
|
|
|
29
|
$self->v("marking reachable objects...\n"); |
58
|
|
|
|
|
|
|
|
59
|
9
|
|
|
|
|
248
|
return $self->mark_scan->results; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
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
|
|
|
9
|
|
14
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
9
|
|
|
|
|
221
|
return $self->sweep_scan->results; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__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
|
|
|
|
|
|
|
|