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