| 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
Condition33%1/3
$INC{"threads.pm"} and not $^O =~ /mswin|mingw|msys|cygwin/i
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 499 | $impl = ucfirst( lc $impl ); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 499 | ▶ | eval "require MCE::Mutex::$impl; 1;" || | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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'
MC/DC0%0/1
$_[0]{'impl'} || 'Not defined'
$_[0]{'impl'}
Truth table50%1/2
A
A= $_[0]{'impl'}
| |||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 112 | 1; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||