… | |
… | |
31 | watcher constructors from Event is that you do not specify a callback |
31 | watcher constructors from Event is that you do not specify a callback |
32 | function - it will be managed by this module. |
32 | function - it will be managed by this module. |
33 | |
33 | |
34 | Your application should just create all necessary coroutines and then call |
34 | Your application should just create all necessary coroutines and then call |
35 | Coro::Event::loop. |
35 | Coro::Event::loop. |
|
|
36 | |
|
|
37 | Please note that even programs or modules (such as |
|
|
38 | L<Coro::Handle|Coro::Handle>) that use "traditional" |
|
|
39 | event-based/continuation style will run more efficient with this module |
|
|
40 | then when using only Event. |
36 | |
41 | |
37 | =over 4 |
42 | =over 4 |
38 | |
43 | |
39 | =cut |
44 | =cut |
40 | |
45 | |
… | |
… | |
148 | |
153 | |
149 | This is the version of C<loop> you should use instead of C<Event::loop> |
154 | This is the version of C<loop> you should use instead of C<Event::loop> |
150 | when using this module - it will ensure correct scheduling in the presence |
155 | when using this module - it will ensure correct scheduling in the presence |
151 | of events. |
156 | of events. |
152 | |
157 | |
153 | =begin comment |
|
|
154 | |
|
|
155 | Unlike loop's counterpart it is not an error when no watchers are active - |
|
|
156 | loop silently returns in this case, as if unloop(undef) were called. |
|
|
157 | |
|
|
158 | =end comment |
|
|
159 | |
|
|
160 | =cut |
|
|
161 | |
|
|
162 | # no longer do something special - it's done internally now |
|
|
163 | |
|
|
164 | #sub loop(;$) { |
|
|
165 | # #local $Coro::idle = $Coro::current; |
|
|
166 | # #Coro::schedule; # become idle task, which is implicitly ready |
|
|
167 | # &Event::loop; |
|
|
168 | #} |
|
|
169 | |
|
|
170 | =item unloop([$result]) |
158 | =item unloop([$result]) |
171 | |
159 | |
172 | Same as Event::unloop (provided here for your convinience only). |
160 | Same as Event::unloop (provided here for your convinience only). |
173 | |
161 | |
174 | =cut |
162 | =cut |
175 | |
163 | |
176 | $Coro::idle = new Coro sub { |
164 | $Coro::idle = new Coro sub { |
177 | while () { |
165 | while () { |
|
|
166 | Coro::schedule; |
178 | Event::one_event; # inefficient |
167 | Event::one_event; # inefficient |
179 | Coro::schedule; |
|
|
180 | } |
168 | } |
181 | }; |
169 | }; |
182 | |
170 | |
183 | # provide hooks for Coro::Timer |
171 | # provide hooks for Coro::Timer |
184 | |
172 | |
… | |
… | |
191 | }; |
179 | }; |
192 | } |
180 | } |
193 | |
181 | |
194 | 1; |
182 | 1; |
195 | |
183 | |
|
|
184 | =back |
|
|
185 | |
196 | =head1 AUTHOR |
186 | =head1 AUTHOR |
197 | |
187 | |
198 | Marc Lehmann <schmorp@schmorp.de> |
188 | Marc Lehmann <schmorp@schmorp.de> |
199 | http://home.schmorp.de/ |
189 | http://home.schmorp.de/ |
200 | |
190 | |