line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ubic::SingletonLock; |
2
|
|
|
|
|
|
|
$Ubic::SingletonLock::VERSION = '1.58_01'; # TRIAL |
3
|
25
|
|
|
25
|
|
114
|
use strict; |
|
25
|
|
|
|
|
38
|
|
|
25
|
|
|
|
|
689
|
|
4
|
25
|
|
|
25
|
|
102
|
use warnings; |
|
25
|
|
|
|
|
34
|
|
|
25
|
|
|
|
|
608
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: lock which can be safely created several times from the same process without deadlocking |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
25
|
|
|
25
|
|
104
|
use Params::Validate; |
|
25
|
|
|
|
|
31
|
|
|
25
|
|
|
|
|
1383
|
|
10
|
25
|
|
|
25
|
|
120
|
use Scalar::Util qw(weaken); |
|
25
|
|
|
|
|
37
|
|
|
25
|
|
|
|
|
1182
|
|
11
|
|
|
|
|
|
|
|
12
|
25
|
|
|
25
|
|
111
|
use Ubic::Lockf; |
|
25
|
|
|
|
|
37
|
|
|
25
|
|
|
|
|
5318
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %LOCKS; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
57
|
|
|
57
|
1
|
507
|
my ($class, $file, $options) = validate_pos(@_, 1, 1, 0); |
18
|
|
|
|
|
|
|
|
19
|
57
|
100
|
|
|
|
240
|
if ($LOCKS{$file}) { |
20
|
24
|
|
|
|
|
166
|
return $LOCKS{$file}; |
21
|
|
|
|
|
|
|
} |
22
|
33
|
|
|
|
|
166
|
my $lock = lockf($file, $options); |
23
|
33
|
|
|
|
|
305
|
my $self = bless { file => $file, lock => $lock } => $class; |
24
|
|
|
|
|
|
|
|
25
|
33
|
|
|
|
|
106
|
$LOCKS{$file} = $self; |
26
|
33
|
|
|
|
|
210
|
weaken $LOCKS{$file}; |
27
|
33
|
|
|
|
|
285
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub DESTROY { |
31
|
30
|
|
|
30
|
|
2518968
|
my $self = shift; |
32
|
30
|
|
|
|
|
52
|
local $@; |
33
|
30
|
|
|
|
|
264
|
delete $LOCKS{ $self->{file} }; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |