File Coverage

blib/lib/AnyEvent/Impl/Perl.pm
Criterion Covered Total %
statement 12 15 80.0
branch n/a
condition n/a
subroutine 6 8 75.0
pod 0 4 0.0
total 18 27 66.6


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             AnyEvent::Impl::Perl - AnyEvent adaptor for AnyEvent's pure perl AnyEvent::Loop
4              
5             =head1 SYNOPSIS
6              
7             use AnyEvent;
8             use AnyEvent::Loop;
9             # this module gets loaded automatically as required
10              
11             =head1 DESCRIPTION
12              
13             This module provides transparent support for AnyEvent in case no other
14             event loop could be found or loaded.
15              
16             If you want to use this module instead of autoloading another event loop
17             you can simply load L before creating the first watcher.
18              
19             Naturally, it supports all features of AnyEvent.
20              
21             See L for more details on performance characteristics.
22              
23             =cut
24              
25             package AnyEvent::Impl::Perl;
26              
27 13     13   5864 use AnyEvent (); BEGIN { AnyEvent::common_sense }
  13     13   110  
  13         329  
  13         62  
28 13     13   5271 use AnyEvent::Loop;
  13         36  
  13         3707  
29              
30             our $VERSION = $AnyEvent::VERSION;
31              
32             # time() is provided via AnyEvent::Base
33              
34             *AE::now = \&AnyEvent::Loop::now;
35             *AE::now_update = \&AnyEvent::Loop::now_update;
36             *AE::io = \&AnyEvent::Loop::io;
37             *AE::timer = \&AnyEvent::Loop::timer;
38             *AE::idle = \&AnyEvent::Loop::idle;
39             *_poll = \&AnyEvent::Loop::one_event;
40             *loop = \&AnyEvent::Loop::run; # compatibility with AnyEvent < 6.0
41             *now_update = \&AnyEvent::Loop::now_update;
42              
43 0     0 0 0 sub now { $AnyEvent::Loop::NOW }
44              
45             sub AnyEvent::CondVar::Base::_wait {
46 34     34   241 AnyEvent::Loop::one_event until exists $_[0]{_ae_sent};
47             }
48              
49             sub io {
50 8     8 0 255 my (undef, %arg) = @_;
51              
52             AnyEvent::Loop::io $arg{fh}, $arg{poll} eq "w", $arg{cb}
53 8         32 }
54              
55             sub timer {
56 14     14 0 351 my (undef, %arg) = @_;
57              
58             AnyEvent::Loop::timer $arg{after}, $arg{interval}, $arg{cb}
59 14         168 }
60              
61             sub idle {
62 0     0 0   my (undef, %arg) = @_;
63              
64             AnyEvent::Loop::idle $arg{cb}
65 0           }
66              
67             =head1 SEE ALSO
68              
69             L.
70              
71             =head1 AUTHOR
72              
73             Marc Lehmann
74             http://anyevent.schmorp.de
75              
76             =cut
77              
78             1
79