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

Comparing Coro/Event/Event.pm (file contents):
Revision 1.38 by root, Mon Nov 20 20:14:02 2006 UTC vs.
Revision 1.41 by root, Fri Dec 1 02:17:37 2006 UTC

49 49
50use Carp; 50use Carp;
51no warnings; 51no warnings;
52 52
53use Coro; 53use Coro;
54use Coro::Timer;
54use Event qw(loop unloop); # we are re-exporting this, cooool! 55use Event qw(loop unloop); # we are re-exporting this, cooool!
55 56
56use XSLoader; 57use XSLoader;
57 58
58use base Exporter::; 59use base Exporter::;
59 60
60our @EXPORT = qw(loop unloop sweep reschedule); 61our @EXPORT = qw(loop unloop sweep);
61 62
62BEGIN { 63BEGIN {
63 our $VERSION = 1.9; 64 our $VERSION = 1.9;
64 65
65 local $^W = 0; # avoid redefine warning for Coro::ready; 66 local $^W = 0; # avoid redefine warning for Coro::ready;
122} 123}
123 124
124# double calls to avoid stack-cloning ;() 125# double calls to avoid stack-cloning ;()
125# is about 10% slower, though. 126# is about 10% slower, though.
126sub next($) { 127sub next($) {
127 &Coro::schedule if &_next; $_[0]; 128 &Coro::schedule while &_next;
129
130 $_[0]
128} 131}
129 132
130sub Coro::Event::w { $_[0] } 133sub Coro::Event::w { $_[0] }
131sub Coro::Event::prio { $_[0]{Coro::Event}[3] } 134sub Coro::Event::prio { $_[0]{Coro::Event}[3] }
132sub Coro::Event::hits { $_[0]{Coro::Event}[4] } 135sub Coro::Event::hits { $_[0]{Coro::Event}[4] }
159 162
160Same as Event::unloop (provided here for your convinience only). 163Same as Event::unloop (provided here for your convinience only).
161 164
162=cut 165=cut
163 166
164$Coro::idle = new Coro sub { 167$Coro::idle = \&Event::one_event; # inefficient
165 while () {
166 Coro::schedule;
167 Event::one_event; # inefficient
168 }
169};
170
171# provide hooks for Coro::Timer
172
173package Coro::Timer;
174
175unless ($override) {
176 $override = 1;
177 *_new_timer = sub {
178 Event->timer(at => $_[0], cb => $_[1]);
179 };
180}
181 168
1821; 1691;
183 170
184=back 171=back
185 172

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines