Dancer/SearchApp/Utils.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 37 CC 2 SCAR 11.5
CC
2
Cov
0%
await
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.1
1 package Dancer::SearchApp::Utils;
2 use strict;
3 use Exporter 'import';
4 use AnyEvent;
5  
6 use vars qw(@EXPORT_OK $VERSION);
7 $VERSION = '0.06';
8 @EXPORT_OK = (qw(await));
9  
10 =head1 NAME
11  
12 Dancer::SearchApp::Utils - helper routines
13  
14 =head1 EXPORTS
15  
16 =head2 C<< await >>
17  
18 sub some_routine {
19 my $p = deferred;
20 ...
21 $p->promise
22 }
23  
24 my $result = await some_routine( ... );
25 print $result;
26  
27 Waits for a promise to be fulfilled. Needs L<AnyEvent>
28 to wait for a promise.
29  
30 =cut
31  
32 sub await($) {
33 my $promise = $_[0];
34 my @res;
35 if( $promise->is_unfulfilled ) {
36 require AnyEvent;
37 my $await = AnyEvent->condvar;
38 $promise->then(sub{ $await->send(@_)});
39 @res = $await->recv;
40 } else {
41 @res = @{ $promise->result }
42 }
43 @res
44 };
45  
46 1;
47  
48 =head1 REPOSITORY
49  
50 The public repository of this module is
51 L<https://github.com/Corion/dancer-searchapp>.
52  
53 =head1 SUPPORT
54  
55 The public support forum of this module is
56 L<https://perlmonks.org/>.
57  
58 =head1 TALKS
59  
60 I've given a talk about this module at Perl conferences:
61  
62 L<German Perl Workshop 2016, German|http://corion.net/talks/dancer-searchapp/dancer-searchapp.html>
63  
64 =head1 BUG TRACKER
65  
66 Please report bugs in this module via the RT CPAN bug queue at
67 L<https://rt.cpan.org/Public/Dist/Display.html?Name=Dancer-SearchApp>
68 or via mail to L<dancer-searchapp-Bugs@rt.cpan.org>.
69  
70 =head1 AUTHOR
71  
72 Max Maischein C<corion@cpan.org>
73  
74 =head1 COPYRIGHT (c)
75  
76 Copyright 2014-2016 by Max Maischein C<corion@cpan.org>.
77  
78 =head1 LICENSE
79  
80 This module is released under the same terms as Perl itself.
81  
82 =cut