Xmldoom/Threads.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 40 CC 5 SCAR 19.6
CC
5
Cov
0%
make_shared
12.0
BEGIN
6.0
is_shared
6.0
CRAP 7.1
1  
2 package Xmldoom::Threads;
3  
4 use Module::Runtime qw(use_module);
5 use strict;
6  
7 BEGIN
8 {
9 if ( $threads::threads )
10 {
11 use_module 'Thread::Shared';
12 }
13 }
14  
15 sub make_shared
16 {
17 my $value = shift;
18 my $shared = shift;
19  
20 if ( $shared )
21 {
22 if ( $threads::threads )
23 {
24 return Thread::Shared::convert($value);
25 }
26 else
27 {
28 print "WARNING: Unable to copy this value into shared memory because threading is not enabled. Use module 'threads' as close to the beginning of your script as possible to enable.";
29 }
30 }
31  
32 return $value;
33 }
34  
35 sub is_shared
36 {
37 my $value = shift;
38  
39 if ( $threads::threads and Thread::Shared::one_of_us($value) )
40 {
41 return 1;
42 }
43  
44 return 0;
45 }
46  
47 1;
48