blib/lib/POSIX/RT/Semaphore.pm

filter: Statementstmt 62.7% 32 / 51 Branchbran 16.6% 1 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 100% 2 / 2 totaltotal 63.8% 46 / 72 CC 6 SCAR 13.0
CC
6
Cov
58%
BEGIN
8.0
__ANON__
6.0
__ANON__
6.0
CRAP 3.7
↑ Summary Semaphore.xs »
1 package POSIX::RT::Semaphore;
2 #============================================================================#
3  
4 16 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 our ($VERSION, @EXPORT_OK);
7  
8 16 ▶BEGIN {
Subroutine BEGIN: called CC=4 SCAR=20.8
9 16 $VERSION = '0.05_02';
10 16 require XSLoader;
11 16 XSLoader::load(__PACKAGE__, $VERSION);
12  
13 # -- awkwardness to support threaded
14 # operation
15 16 ▶if ($INC{'threads.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"threads.pm"}) 0 16 16
16 0 require threads::shared;
17 16 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 0 for ('Unnamed::init', 'Named::open') {
20 16 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 0 my $sym = __PACKAGE__ . "::$_";
23 0 my $ctor = \&{$sym};
24 0 ▶ *{$sym} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
25 0 my $psem = &$ctor;
26 0 ▶ &threads::shared::share($psem) if defined $psem;
Branch: 1 branch
BranchTrueFalseTotal
if defined $psem 0 0 0
27 0 $psem;
28 }
29 0 }
30  
31 0 for ('Unnamed', 'Named') {
32 16 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 0 my $sym = __PACKAGE__ . "::${_}::DESTROY";
35 0 my $dtor = \&{$sym};
36 0 ▶ *{$sym} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
37 0 lock($_[0]);
38 0 ▶ return unless threads::shared::_refcnt($_[0]) == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless threads::shared::_refcnt($_[0]) == 1 0 0 0
39 0 &$dtor;
40 }
41 0 }
42 } # -- if ($INC{'threads.pm'})
43  
44 }
45  
46 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 #
50 # -- Internal methods
51 #
52  
53 22 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
54 22 require Exporter;
55 22 goto &Exporter::import;
56 }
57  
58 #
59 # -- Public methods
60 #
61  
62 9 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod documented
63 9 shift @_;
64 9 return POSIX::RT::Semaphore::Unnamed->init(@_);
65 }
66  
67 15 ▶sub open {
Subroutine open: called CC=1 SCAR=0.0
Pod documented
68 15 shift @_;
69 15 return POSIX::RT::Semaphore::Named->open(@_);
70 }
71  
72 16 1;
73  
74 __END__
↑ Summary Semaphore.xs »