File Coverage

blib/lib/AnyEvent/Capture.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             # ABSTRACT: Call asynchronous APIs synchronously
2             package AnyEvent::Capture;
3             {
4             $AnyEvent::Capture::VERSION = '0.1.1';
5             }
6 1     1   45144 use strict;
  1         3  
  1         41  
7 1     1   5 use warnings;
  1         3  
  1         30  
8 1     1   4320 use AnyEvent ();
  1         6311  
  1         41  
9 1         14 use Sub::Exporter -setup => {
10             exports => [qw( capture )],
11             groups => { default => [qw( capture )] },
12 1     1   2764 };
  1         17664  
13              
14              
15             sub capture(&) {
16 2     2 1 1222 my( $todo ) = @_;
17 2         77 my $cv = AE::cv;
18 2     2   15573 my(@results) = $todo->( sub { $cv->send(@_) } );
  2         493875  
19 2         135 return $cv->recv;
20             }
21              
22             1;
23              
24              
25             __END__