File Coverage

blib/lib/Future/XS.pm
Criterion Covered Total %
statement 22 28 78.5
branch 2 4 50.0
condition n/a
subroutine 7 7 100.0
pod n/a
total 31 39 79.4


line stmt bran cond sub pod time code
1             # You may distribute under the terms of either the GNU General Public License
2             # or the Artistic License (the same terms as Perl itself)
3             #
4             # (C) Paul Evans, 2022 -- leonerd@leonerd.org.uk
5              
6             package Future::XS 0.09;
7              
8 2     2   104961 use v5.14;
  2         15  
9 2     2   11 use warnings;
  2         3  
  2         75  
10              
11 2     2   11 use Carp;
  2         4  
  2         183  
12              
13             require XSLoader;
14             XSLoader::load( __PACKAGE__, our $VERSION );
15              
16 2     2   13 use Time::HiRes qw( tv_interval );
  2         4  
  2         19  
17              
18             # Future::_base is provided in Future.pm itself
19             require Future;
20             our @ISA = qw( Future::_base );
21              
22             our @CARP_NOT = qw( Future Future::_base );
23              
24             require Future::Exception;
25              
26             =head1 NAME
27              
28             C - experimental XS implementation of C
29              
30             =head1 SYNOPSIS
31              
32             my $future = Future::XS->new;
33              
34             perform_some_operation(
35             on_complete => sub {
36             $future->done( @_ );
37             }
38             );
39              
40             $future->on_ready( sub {
41             say "The operation is complete";
42             } );
43              
44             =head1 DESCRIPTION
45              
46             This module provides an XS-based implementation of the L class. It is
47             currently experimental and shipped in its own distribution for testing
48             purposes, though once it seems stable the plan is to move it into the main
49             C distribution and load it automatically in favour of the pureperl
50             implementation on supported systems.
51              
52             =cut
53              
54             sub import
55             {
56 2     2   14 my $pkg = shift;
57 2         4 my $caller = caller;
58              
59 2         11 my %syms = map { $_ => 1 } @_;
  0         0  
60              
61 2 50       23 if( delete $syms{"-default"} ) {
62 0         0 require Future;
63              
64 2     2   518 no warnings 'redefine';
  2         13  
  2         116  
65 0         0 foreach my $name (qw( new done fail )) {
66 2     2   13 no strict 'refs';
  2         4  
  2         308  
67 0         0 *{"Future::${name}"} = \&{__PACKAGE__."::${name}"};
  0         0  
  0         0  
68             }
69             }
70              
71 2 50       72 croak "Unrecognised $pkg\->import symbols - " . join( ", ", sort keys %syms )
72             if %syms;
73             }
74              
75             =head1 AUTHOR
76              
77             Paul Evans
78              
79             =cut
80              
81             0x55AA;