… | |
… | |
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 | |
|
|
46 | Blocks the coroutine until either the given event set has occured on the |
|
|
47 | fd, or the timeout has been reached (if timeout is zero, there is no |
|
|
48 | timeout). Returns the received flags. |
|
|
49 | |
|
|
50 | =item Coro::EV::timer_once $after |
|
|
51 | |
|
|
52 | Blocks the coroutine for at least C<$after> seconds. |
|
|
53 | |
|
|
54 | =cut |
|
|
55 | |
|
|
56 | # relatively inefficient |
40 | # relatively inefficient |
57 | our $ev_idle = new Coro sub { |
41 | our $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 | |
|
|
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 | |
67 | sub timed_io_once($$;$) { |
59 | sub 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 | |
|
|
67 | Blocks the coroutine for at least C<$after> seconds. |
|
|
68 | |
|
|
69 | =cut |
72 | |
70 | |
73 | sub timer_once($) { |
71 | sub timer_once($) { |
74 | &_timer_once; |
72 | &_timer_once; |
75 | do { &Coro::schedule } while !$#_; |
73 | do { &Coro::schedule } while !$#_; |
76 | pop |
74 | pop |