File Coverage

blib/lib/Data/PubSub/Shared.pm
Criterion Covered Total %
statement 15 17 88.2
branch n/a
condition n/a
subroutine 6 8 75.0
pod n/a
total 21 25 84.0


line stmt bran cond sub pod time code
1             package Data::PubSub::Shared;
2 24     24   2710182 use strict;
  24         39  
  24         840  
3 24     24   106 use warnings;
  24         35  
  24         2109  
4             our $VERSION = '0.07';
5              
6             require XSLoader;
7             XSLoader::load('Data::PubSub::Shared', $VERSION);
8              
9             # ithreads: blessed shared-memory handles must never be cloned into a
10             # child thread -- the clone would double-free the handle on thread exit.
11 24     24   285 { no strict 'refs'; *{"${_}::CLONE_SKIP"} = sub { 1 } for qw(
  24     0   41  
  24         4890  
  0         0  
12             Data::PubSub::Shared::Int
13             Data::PubSub::Shared::Int::Sub
14             Data::PubSub::Shared::Int16
15             Data::PubSub::Shared::Int16::Sub
16             Data::PubSub::Shared::Int32
17             Data::PubSub::Shared::Int32::Sub
18             Data::PubSub::Shared::Str
19             Data::PubSub::Shared::Str::Sub
20             ); }
21              
22             sub _enable_keywords {
23 6     6   16 my ($pkg, @kws) = @_;
24 6         2107 $^H{"$pkg/$_"} = 1 for @kws;
25             }
26              
27             for my $variant (qw(Int Int32 Int16 Str)) {
28             my $lc = lc $variant;
29             my $pkg = "Data::PubSub::Shared::$variant";
30             my @kws = map { "ps_${lc}_$_" } qw(publish poll lag);
31 24     24   123 no strict 'refs';
  24         68  
  24         4079  
32             *{"${pkg}::import"} = sub {
33 6     6   48 _enable_keywords($pkg, @kws);
34             };
35             *{"${pkg}::unimport"} = sub {
36 0     0     delete $^H{"$pkg/$_"} for @kws;
37             };
38             }
39              
40             1;
41              
42             __END__