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 SCAR 16.4
CC
5
Cov
82%
new
4.0
impl
2.1
BEGIN
1.0
CRAP 5.1
« MCE/Channel.pm ↑ Summary
1 ###############################################################################
2 ## ----------------------------------------------------------------------------
3 ## Locking for Many-Core Engine.
4 ##
5 ###############################################################################
6  
7 package MCE::Mutex;
8  
9 106 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 106 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 106 ▶no warnings qw( threads recursion uninitialized );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 106 our $VERSION = '1.889';
15  
16 ## no critic (BuiltinFunctions::ProhibitStringyEval)
17 ## no critic (TestingAndDebugging::ProhibitNoStrict)
18  
19 106 ▶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 106 ▶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 106 106
Condition33%1/3
$INC{"threads.pm"} and not $^O =~ /mswin|mingw|msys|cygwin/i
!ll&&!rl&&r
10600
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 sub new {
30 463 ▶ my ($class, %argv) = @_;
Subroutine new: called CC=4 SCAR=13.9
Pod documented
31 my $impl = defined($argv{impl})
32 463 ▶ ? $argv{impl} : defined($argv{path}) ? 'Flock' : 'Channel';
Branch: 2 branches
BranchTrueFalseTotal
defined $argv{'impl'} ? : 410 53 463
defined $argv{'path'} ? : 1 52 53
33  
34 463 $impl = ucfirst( lc $impl );
35  
36 463 ▶ 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}': $@") 0 463 463
37 Carp::croak("Could not load Mutex implementation '$impl': $@");
38  
39 463 my $pkg = 'MCE::Mutex::'.$impl;
40 106 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 463 return $pkg->new( %argv );
43 }
44  
45 ## base class method
46  
47 sub impl {
48 5 ▶ return $_[0]->{impl} || 'Not defined';
Subroutine impl: called CC=2 SCAR=7.6
Pod documented
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 106 1;
52  
53 __END__
« MCE/Channel.pm ↑ Summary