line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################### |
2
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
## Mutex - Various locking implementations supporting processes and threads. |
4
|
|
|
|
|
|
|
## |
5
|
|
|
|
|
|
|
############################################################################### |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Mutex; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
200158
|
use strict; |
|
3
|
|
|
|
|
23
|
|
|
3
|
|
|
|
|
83
|
|
10
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
110
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '1.008'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
## no critic (BuiltinFunctions::ProhibitStringyEval) |
15
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
15
|
use Carp (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
338
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
4
|
|
|
4
|
1
|
261
|
my ($class, %argv) = @_; |
21
|
|
|
|
|
|
|
my $impl = defined($argv{impl}) |
22
|
4
|
100
|
|
|
|
56
|
? $argv{impl} : defined($argv{path}) ? 'Flock' : 'Channel'; |
|
|
100
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
18
|
$impl = ucfirst( lc $impl ); |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
237
|
eval "require Mutex::$impl; 1;" || |
27
|
|
|
|
|
|
|
Carp::croak("Could not load Mutex implementation '$impl': $@"); |
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
|
|
19
|
my $pkg = 'Mutex::'.$impl; |
30
|
3
|
|
|
3
|
|
19
|
no strict 'refs'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
310
|
|
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
23
|
return $pkg->new( %argv ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
## base class method |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub impl { |
38
|
4
|
|
50
|
4
|
1
|
55
|
return $_[0]->{impl} || 'Not defined'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |