line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sweet::File::Semaphore; |
2
|
2
|
|
|
2
|
|
8137960
|
use v5.12; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
102
|
|
3
|
2
|
|
|
2
|
|
275
|
use Moose; |
|
2
|
|
|
|
|
276625
|
|
|
2
|
|
|
|
|
10
|
|
4
|
2
|
|
|
2
|
|
8764
|
use namespace::autoclean; |
|
2
|
|
|
|
|
1025
|
|
|
2
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'Sweet::File'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
288
|
use Sweet::Types; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has linked_file => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => 'Sweet::File', |
13
|
|
|
|
|
|
|
coerce => 1, |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
21
|
sub _build_lines { return [$$] } |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
19
|
sub _build_extension { 'ok' } |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
22
|
sub _build_dir { shift->linked_file->dir } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _build_name { |
24
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
21
|
my $extension = $self->extension; |
27
|
1
|
|
|
|
|
23
|
my $linked_file = $self->linked_file; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
20
|
my $name = $linked_file->name . '.' . $extension; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
18
|
return $name; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Sweet::File::Semaphore |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Sweet::File::Semaphore; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $file = Sweet::File->new( |
49
|
|
|
|
|
|
|
dir => '/path/to/dir', |
50
|
|
|
|
|
|
|
name => 'foo.dat', |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $semaphore = Sweet::File::Semaphore->new(linked_file=>$file); |
54
|
|
|
|
|
|
|
say $semaphore; # /path/to/dir/foo.dat.ok |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$semaphore->write; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 INHERITANCE |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Inherits from L<Sweet::File>. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 linked_file |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Instance of L<Sweet::File>. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 PRIVATE METHODS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 _build_extension |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Returns C<ok>. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 _build_dir |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns L</linked_file> dir. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 _build_name |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns L</linked_file> name suffixed with C<.extension>. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 _build_lines |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns one line containing PID. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|