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
|
|
210670
|
use strict; |
|
3
|
|
|
|
|
29
|
|
|
3
|
|
|
|
|
91
|
|
10
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
116
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '1.011'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
## no critic (BuiltinFunctions::ProhibitStringyEval) |
15
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
20
|
use Carp (); |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
349
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
4
|
|
|
4
|
1
|
246
|
my ($class, %argv) = @_; |
21
|
|
|
|
|
|
|
my $impl = defined($argv{impl}) |
22
|
4
|
100
|
|
|
|
22
|
? $argv{impl} : defined($argv{path}) ? 'Flock' : 'Channel'; |
|
|
100
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
17
|
$impl = ucfirst( lc $impl ); |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
247
|
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
|
|
21
|
no strict 'refs'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
311
|
|
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
25
|
return $pkg->new( %argv ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
## base class method |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub impl { |
38
|
4
|
|
50
|
4
|
1
|
56
|
return $_[0]->{impl} || 'Not defined'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |