ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/EV/EV.pm
(Generate patch)

Comparing Coro/EV/EV.pm (file contents):
Revision 1.2 by root, Thu Nov 1 06:34:32 2007 UTC vs.
Revision 1.3 by root, Thu Nov 1 06:58:21 2007 UTC

35 35
36 local $^W = 0; # avoid redefine warning for Coro::ready; 36 local $^W = 0; # avoid redefine warning for Coro::ready;
37 XSLoader::load __PACKAGE__, $VERSION; 37 XSLoader::load __PACKAGE__, $VERSION;
38} 38}
39 39
40=cut
41
42=item
43
44=item $revents = Coro::EV::timed_io_once $fd, $events, $timeout
45
46Blocks the coroutine until either the given event set has occured on the
47fd, or the timeout has been reached (if timeout is zero, there is no
48timeout). Returns the received flags.
49
50=item Coro::EV::timer_once $after
51
52Blocks the coroutine for at least C<$after> seconds.
53
54=cut
55
56# relatively inefficient 40# relatively inefficient
57our $ev_idle = new Coro sub { 41our $ev_idle = new Coro sub {
58 while () { 42 while () {
59 EV::loop EV::LOOP_ONESHOT; 43 EV::loop EV::LOOP_ONESHOT;
60 &Coro::schedule; 44 &Coro::schedule;
62}; 46};
63$ev->{desc} = "[EV idle process]"; 47$ev->{desc} = "[EV idle process]";
64 48
65$Coro::idle = sub { $ev_idle->ready }; 49$Coro::idle = sub { $ev_idle->ready };
66 50
51=item $revents = Coro::EV::timed_io_once $fd, $events, $timeout
52
53Blocks the coroutine until either the given event set has occured on the
54fd, or the timeout has been reached (if timeout is zero, there is no
55timeout). Returns the received flags.
56
57=cut
58
67sub timed_io_once($$;$) { 59sub timed_io_once($$;$) {
68 &_timed_io_once; 60 &_timed_io_once;
69 do { &Coro::schedule } while !$#_; 61 do { &Coro::schedule } while !$#_;
70 pop 62 pop
71} 63}
64
65=item Coro::EV::timer_once $after
66
67Blocks the coroutine for at least C<$after> seconds.
68
69=cut
72 70
73sub timer_once($) { 71sub timer_once($) {
74 &_timer_once; 72 &_timer_once;
75 do { &Coro::schedule } while !$#_; 73 do { &Coro::schedule } while !$#_;
76 pop 74 pop

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines