ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Impl/Event.pm
Revision: 1.28
Committed: Sat Apr 25 20:27:47 2009 UTC (15 years, 2 months ago) by root
Branch: MAIN
CVS Tags: rel-4_4, rel-4_411, rel-4_41
Changes since 1.27: +1 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.16 =head1 NAME
2    
3     AnyEvent::Impl::Event - AnyEvent adaptor for Event
4    
5     =head1 SYNOPSIS
6    
7 root 1.21 use AnyEvent;
8 root 1.25 use Event;
9 root 1.21
10     # this module gets loaded automatically as required
11 root 1.16
12     =head1 DESCRIPTION
13    
14     This module provides transparent support for AnyEvent. You don't have to
15     do anything to make Event work with AnyEvent except by loading Event before
16     creating the first AnyEvent watcher.
17    
18 root 1.24 The event module is reasonably efficient and generally works correctly
19     even with many watchers.
20    
21 root 1.16 =cut
22    
23 root 1.1 package AnyEvent::Impl::Event;
24    
25 root 1.12 no warnings;
26 root 1.15 use strict;
27 root 1.12
28 root 1.20 use AnyEvent ();
29 root 1.19
30 root 1.27 use Event qw(unloop); # we have to import something to make Event use Time::HiRes
31 root 1.1
32 root 1.2 sub io {
33     my ($class, %arg) = @_;
34     $arg{fd} = delete $arg{fh};
35 root 1.20 $arg{poll} .= "e" if AnyEvent::WIN32; # work around windows connect bug
36 root 1.13 bless \(Event->io (%arg)), $class
37 root 1.2 }
38    
39     sub timer {
40     my ($class, %arg) = @_;
41 root 1.28 $arg{after} = 0 if $arg{after} < 0;
42 root 1.23 bless \Event->timer (%arg, repeat => $arg{interval}), $class
43 root 1.2 }
44    
45 root 1.13 sub signal {
46     my ($class, %arg) = @_;
47 root 1.18 bless \Event->signal (%arg), $class
48 root 1.13 }
49    
50 root 1.27 sub idle {
51     my ($class, %arg) = @_;
52     bless \Event->idle (repeat => 1, min => 0, %arg), $class
53     }
54    
55 root 1.7 sub DESTROY {
56 root 1.9 ${$_[0]}->cancel;
57 root 1.1 }
58    
59 root 1.11 sub one_event {
60     Event::one_event;
61 root 1.1 }
62    
63 root 1.16 1;
64    
65     =head1 SEE ALSO
66    
67 root 1.17 L<AnyEvent>, L<Event>.
68 root 1.16
69     =head1 AUTHOR
70    
71     Marc Lehmann <schmorp@schmorp.de>
72     http://home.schmorp.de/
73    
74     =cut
75 root 1.1