MCE/Mutex.pm

filter: Statementstmt 92.5% 25 / 27 Branchbran 75.0% 6 / 8 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 80.7% 42 / 52 CC 5 SCAR 8.3
CC
5
Cov
82%
new
4.0
impl
2.1
BEGIN
1.0
CRAP 2.3
« MCE/Channel.pm ↑ Summary MCE/Core.pm »
1 ###############################################################################
2 ## ----------------------------------------------------------------------------
3 ## Locking for Many-Core Engine.
4 ##
5 ###############################################################################
6  
7 package MCE::Mutex;
8  
9 112 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 112 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 112 ▶no warnings qw( threads recursion uninitialized );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 112 our $VERSION = '1.904';
15  
16 ## no critic (BuiltinFunctions::ProhibitStringyEval)
17 ## no critic (TestingAndDebugging::ProhibitNoStrict)
18  
19 112 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 ## global Mutex used by MCE, MCE::Child, and MCE::Hobo inside threads
22 ## on UNIX platforms
23  
24 112 ▶if ( $INC{'threads.pm'} && $^O !~ /mswin|mingw|msys|cygwin/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"threads.pm"} and not $^O =~ /mswin|mingw|msys|cygwin/i) 0 112 112
Condition33%1/3
$INC{"threads.pm"} and not $^O =~ /mswin|mingw|msys|cygwin/i
!ll&&!rl&&r
11200
MC/DC0%0/2
$INC{"threads.pm"} and not $^O =~ /mswin|mingw|msys|cygwin/i
$INC{"threads.pm"} not $^O =~ /mswin|mingw|msys|cygwin/i
Truth table33%1/3
A and not(B)
A= $INC{"threads.pm"}B= not $^O =~ /mswin|mingw|msys|cygwin/i
ABresult
0X0
100
111
25 0 $MCE::_GMUTEX = MCE::Mutex->new( impl => 'Channel' );
26 0 MCE::Mutex::Channel::_save_for_global_cleanup($MCE::_GMUTEX);
27 }
28  
29 499 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
30 499 my ($class, %argv) = @_;
31 my $impl = defined($argv{impl})
32 499 ▶ ? $argv{impl} : defined($argv{path}) ? 'Flock' : 'Channel';
Branch: 2 branches
BranchTrueFalseTotal
defined $argv{'impl'} ? : 446 53 499
defined $argv{'path'} ? : 1 52 53
33  
34 499 $impl = ucfirst( lc $impl );
35  
36 499 ▶ eval "require MCE::Mutex::$impl; 1;" ||
Branch: 1 branch
BranchTrueFalseTotal
eval "require MCE::Mutex::$impl; 1;" or Carp::croak("Could not load Mutex implementation '${impl}': $@") 499 0 499
37 Carp::croak("Could not load Mutex implementation '$impl': $@");
38  
39 499 my $pkg = 'MCE::Mutex::'.$impl;
40 112 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 499 return $pkg->new( %argv );
43 }
44  
45 ## base class method
46  
47 5 ▶sub impl {
Subroutine impl: called CC=2 SCAR=7.6
Pod documented
48 5 ▶ return $_[0]->{impl} || 'Not defined';
Condition50%1/2
$_[0]{'impl'} || 'Not defined'
l!l
50
MC/DC0%0/1
$_[0]{'impl'} || 'Not defined'
$_[0]{'impl'}
Truth table50%1/2
A
A= $_[0]{'impl'}
Aresult
11
00
49 }
50  
51 112 1;
52  
53 __END__
« MCE/Channel.pm ↑ Summary MCE/Core.pm »