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.29 |
sub loop { |
64 |
|
|
Event::loop; |
65 |
|
|
} |
66 |
|
|
|
67 |
root |
1.16 |
1; |
68 |
|
|
|
69 |
|
|
=head1 SEE ALSO |
70 |
|
|
|
71 |
root |
1.17 |
L<AnyEvent>, L<Event>. |
72 |
root |
1.16 |
|
73 |
|
|
=head1 AUTHOR |
74 |
|
|
|
75 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
76 |
|
|
http://home.schmorp.de/ |
77 |
|
|
|
78 |
|
|
=cut |
79 |
root |
1.1 |
|