… | |
… | |
76 | |
76 | |
77 | =cut |
77 | =cut |
78 | |
78 | |
79 | package Coro::Event; |
79 | package Coro::Event; |
80 | |
80 | |
81 | no warnings; |
81 | use common::sense; |
82 | |
82 | |
83 | use Carp; |
83 | use Carp; |
84 | no warnings; |
|
|
85 | |
84 | |
86 | use Coro; |
85 | use Coro; |
87 | use Event qw(loop unloop); # we are re-exporting this for historical reasons |
86 | use Event qw(loop unloop); # we are re-exporting this for historical reasons |
88 | |
87 | |
89 | use XSLoader; |
88 | use XSLoader; |
… | |
… | |
91 | use base Exporter::; |
90 | use base Exporter::; |
92 | |
91 | |
93 | our @EXPORT = qw(loop unloop sweep); |
92 | our @EXPORT = qw(loop unloop sweep); |
94 | |
93 | |
95 | BEGIN { |
94 | BEGIN { |
96 | our $VERSION = 5.162; |
95 | our $VERSION = 6.57; |
97 | |
96 | |
98 | local $^W = 0; # avoid redefine warning for Coro::ready; |
97 | local $^W = 0; # avoid redefine warning for Coro::ready; |
99 | XSLoader::load __PACKAGE__, $VERSION; |
98 | XSLoader::load __PACKAGE__, $VERSION; |
100 | } |
99 | } |
101 | |
100 | |
… | |
… | |
119 | |
118 | |
120 | =cut |
119 | =cut |
121 | |
120 | |
122 | =item do_flavour args... |
121 | =item do_flavour args... |
123 | |
122 | |
124 | Create a watcher of the given type and immediately call it's next method, |
123 | Create a watcher of the given type and immediately call its next method, |
125 | returning the event. |
124 | returning the event. |
126 | |
125 | |
127 | This is less efficient then calling the constructor once and the next |
126 | This is less efficient then calling the constructor once and the next |
128 | method often, but it does save typing sometimes. |
127 | method often, but it does save typing sometimes. |
129 | |
128 | |
… | |
… | |
191 | } |
190 | } |
192 | |
191 | |
193 | # very inefficient |
192 | # very inefficient |
194 | our $IDLE = new Coro sub { |
193 | our $IDLE = new Coro sub { |
195 | while () { |
194 | while () { |
196 | &Event::one_event; |
195 | Event::one_event; |
197 | &Coro::schedule; |
196 | Coro::schedule if Coro::nready; |
198 | } |
197 | } |
199 | }; |
198 | }; |
200 | $IDLE->{desc} = "[Event idle process]"; |
199 | $IDLE->{desc} = "[Event idle thread]"; |
201 | |
200 | |
202 | $Coro::idle = $IDLE; |
201 | $Coro::idle = $IDLE; |
203 | |
202 | |
204 | 1; |
203 | 1; |
205 | |
204 | |
206 | =back |
205 | =back |
207 | |
206 | |
208 | =head1 AUTHOR |
207 | =head1 AUTHOR/SUPPORT/CONTACT |
209 | |
208 | |
210 | Marc Lehmann <schmorp@schmorp.de> |
209 | Marc A. Lehmann <schmorp@schmorp.de> |
211 | http://home.schmorp.de/ |
210 | http://software.schmorp.de/pkg/Coro.html |
212 | |
211 | |
213 | =cut |
212 | =cut |
214 | |
213 | |