line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Synchronized::FileLock; |
2
|
3
|
|
|
3
|
|
26
|
use strict; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
98
|
|
3
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
87
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
14
|
use base qw(Test::Synchronized::Lock); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2004
|
|
6
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw(id)); |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
22
|
use File::Spec; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
540
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
3
|
|
|
3
|
1
|
8
|
my ($class, @args) = @_; |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
|
|
25
|
my $self = $class->SUPER::new(@args); |
14
|
3
|
|
|
|
|
61
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _dir { |
18
|
13
|
|
|
13
|
|
50
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
|
20
|
13
|
|
|
|
|
692
|
File::Spec->catfile( |
21
|
|
|
|
|
|
|
File::Spec->tmpdir, |
22
|
|
|
|
|
|
|
sprintf('test-synchronized-%d.lock', $self->id), |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub lock { |
27
|
3
|
|
|
3
|
0
|
5
|
my ($self) = @_; |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
4
|
while (1) { |
30
|
7
|
100
|
|
|
|
74
|
if (! -d $self->_dir) { |
31
|
3
|
50
|
|
|
|
354
|
return if mkdir($self->_dir); |
32
|
|
|
|
|
|
|
} |
33
|
4
|
|
|
|
|
4001066
|
sleep(1); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub unlock { |
38
|
3
|
|
|
3
|
0
|
9
|
my ($self) = @_; |
39
|
3
|
|
|
|
|
14
|
rmdir($self->_dir); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |