| 1 | package POSIX::RT::Semaphore; | ||||||||||
| 2 | #============================================================================# | ||||||||||
| 3 | |||||||||||
| 4 | 15 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 15 | our ($VERSION, @EXPORT_OK); | |||||||||
| 7 | |||||||||||
| 8 | 15 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=16.1
| |||||||||||
| 9 | 15 | $VERSION = '0.05'; | |||||||||
| 10 | 15 | require XSLoader; | |||||||||
| 11 | 15 | XSLoader::load(__PACKAGE__, $VERSION); | |||||||||
| 12 | |||||||||||
| 13 | # -- Set up exports at BEGIN time | ||||||||||
| 14 | @EXPORT_OK = | ||||||||||
| 15 | 15 | ('SIZEOF_SEM_T', grep {/^(_SC_)?SEM_[A-Z_]+/} keys %POSIX::RT::Semaphore::); | |||||||||
| 16 | |||||||||||
| 17 | # -- awkwardness to support threaded | ||||||||||
| 18 | # operation | ||||||||||
| 19 | 15 | ▶ | if ($INC{'threads.pm'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | require threads::shared; | |||||||||
| 21 | 15 | ▶ | no warnings 'redefine'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | 0 | for ('Unnamed::init', 'Named::open') { | |||||||||
| 24 | 15 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 0 | my $sym = __PACKAGE__ . "::$_"; | |||||||||
| 27 | 0 | my $ctor = \&{$sym}; | |||||||||
| 28 | 0 | ▶ | *{$sym} = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 29 | 0 | my $psem = &$ctor; | |||||||||
| 30 | 0 | ▶ | &threads::shared::share($psem) if defined $psem; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | $psem; | |||||||||
| 32 | } | ||||||||||
| 33 | 0 | } | |||||||||
| 34 | |||||||||||
| 35 | 0 | my $dtor = \&POSIX::RT::Semaphore::_base::DESTROY; | |||||||||
| 36 | 0 | ▶ | *POSIX::RT::Semaphore::_base::DESTROY = 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
| |||||||||||
| 39 | 0 | &$dtor; | |||||||||
| 40 | 0 | }; | |||||||||
| 41 | } # -- if ($INC{'threads.pm'}) | ||||||||||
| 42 | |||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 46 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 47 | |||||||||||
| 48 | # | ||||||||||
| 49 | # -- Internal methods | ||||||||||
| 50 | # | ||||||||||
| 51 | |||||||||||
| 52 | 15 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||
| 53 | 15 | require Exporter; | |||||||||
| 54 | 15 | goto &Exporter::import; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | # | ||||||||||
| 58 | # -- Public methods | ||||||||||
| 59 | # | ||||||||||
| 60 | |||||||||||
| 61 | 9 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 62 | 9 | shift @_; | |||||||||
| 63 | 9 | return POSIX::RT::Semaphore::Unnamed->init(@_); | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 15 | ▶ | sub open { | ||||||||
|
Subroutine
open: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 67 | 15 | shift @_; | |||||||||
| 68 | 15 | return POSIX::RT::Semaphore::Named->open(@_); | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 15 | 1; | |||||||||
| 72 | |||||||||||
| 73 | __END__ | ||||||||||