blib/lib/AnyEvent/Impl/EV.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 11 totaltotal 0.0% 0 / 59 CC 2 SCAR 9.4
CC
2
Cov
0%
io
6.0
BEGIN
2.0
time
2.0
CRAP 2.6
1 =head1 NAME
2  
3 AnyEvent::Impl::EV - AnyEvent adaptor for EV
4  
5 =head1 SYNOPSIS
6  
7 use AnyEvent;
8 use EV;
9
10 # this module gets loaded automatically as required
11  
12 =head1 DESCRIPTION
13  
14 This module provides transparent support for AnyEvent. You don't have to
15 do anything to make EV work with AnyEvent except by loading EV before
16 creating the first AnyEvent watcher.
17  
18 =cut
19  
20 package AnyEvent::Impl::EV;
21  
22 use AnyEvent (); BEGIN { AnyEvent::common_sense }
23 use EV 3.44;
24  
25 sub time { EV::time }
26 sub now { EV::now }
27 sub now_update { EV::now_update }
28  
29 *AE::timer = \&EV::timer;
30  
31 sub timer {
32 my ($class, %arg) = @_;
33  
34 EV::timer $arg{after}, $arg{interval}, $arg{cb}
35 }
36  
37 *AE::io = defined &EV::_ae_io
38 ? \&EV::_ae_io
39 : sub($$$) { EV::io $_[0], $_[1] ? EV::WRITE : EV::READ, $_[2] };
40  
41 sub io {
42 my ($class, %arg) = @_;
43  
44 EV::io
45 $arg{fh},
46 $arg{poll} eq "r" ? EV::READ : EV::WRITE,
47 $arg{cb}
48 }
49  
50 sub signal {
51 my ($class, %arg) = @_;
52  
53 EV::signal $arg{signal}, $arg{cb}
54 }
55  
56 *AE::signal = \&EV::signal;
57  
58 sub child {
59 my ($class, %arg) = @_;
60  
61 my $cb = $arg{cb};
62  
63 EV::child $arg{pid}, 0, sub {
64 $cb->($_[0]->rpid, $_[0]->rstatus);
65 }
66 }
67  
68 sub idle {
69 my ($class, %arg) = @_;
70  
71 EV::idle $arg{cb}
72 }
73  
74 *AE::idle = \&EV::idle;
75  
76 sub one_event {
77 EV::loop EV::LOOP_ONESHOT;
78 }
79  
80 sub loop {
81 EV::loop;
82 }
83  
84 1;
85  
86 =head1 SEE ALSO
87  
88 L<AnyEvent>, L<EV>.
89  
90 =head1 AUTHOR
91  
92 Marc Lehmann <schmorp@schmorp.de>
93 http://home.schmorp.de/
94  
95 =cut
96