ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/EV/EV.pm
Revision: 1.3
Committed: Thu Nov 1 06:58:21 2007 UTC (16 years, 7 months ago) by root
Branch: MAIN
Changes since 1.2: +14 -16 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 =head1 NAME
2
3 Coro::EV - do events the coro-way
4
5 =head1 SYNOPSIS
6
7 use Coro;
8 use Coro::EV;
9
10 loop;
11
12 =head1 DESCRIPTION
13
14 =head1 FUNCTIONS
15
16 =over 4
17
18 =cut
19
20 package Coro::EV;
21
22 no warnings;
23
24 use Carp;
25 no warnings;
26
27 use Coro;
28 use Coro::Timer;
29
30 use EV ();
31 use XSLoader;
32
33 BEGIN {
34 our $VERSION = '2.1';
35
36 local $^W = 0; # avoid redefine warning for Coro::ready;
37 XSLoader::load __PACKAGE__, $VERSION;
38 }
39
40 # relatively inefficient
41 our $ev_idle = new Coro sub {
42 while () {
43 EV::loop EV::LOOP_ONESHOT;
44 &Coro::schedule;
45 }
46 };
47 $ev->{desc} = "[EV idle process]";
48
49 $Coro::idle = sub { $ev_idle->ready };
50
51 =item $revents = Coro::EV::timed_io_once $fd, $events, $timeout
52
53 Blocks the coroutine until either the given event set has occured on the
54 fd, or the timeout has been reached (if timeout is zero, there is no
55 timeout). Returns the received flags.
56
57 =cut
58
59 sub timed_io_once($$;$) {
60 &_timed_io_once;
61 do { &Coro::schedule } while !$#_;
62 pop
63 }
64
65 =item Coro::EV::timer_once $after
66
67 Blocks the coroutine for at least C<$after> seconds.
68
69 =cut
70
71 sub timer_once($) {
72 &_timer_once;
73 do { &Coro::schedule } while !$#_;
74 pop
75 }
76
77 #sub timer_abs_once($$) {
78 # &_timer_abs_once;
79 # do { &Coro::schedule } while !$#_;
80 # pop
81 #}
82
83 1;
84
85 =back
86
87 =head1 AUTHOR
88
89 Marc Lehmann <schmorp@schmorp.de>
90 http://home.schmorp.de/
91
92 =cut
93