… | |
… | |
153 | |
153 | |
154 | 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> |
155 | 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 |
156 | of events. |
156 | of events. |
157 | |
157 | |
158 | =begin comment |
|
|
159 | |
|
|
160 | Unlike loop's counterpart it is not an error when no watchers are active - |
|
|
161 | loop silently returns in this case, as if unloop(undef) were called. |
|
|
162 | |
|
|
163 | =end comment |
|
|
164 | |
|
|
165 | =cut |
|
|
166 | |
|
|
167 | # no longer do something special - it's done internally now |
|
|
168 | |
|
|
169 | #sub loop(;$) { |
|
|
170 | # #local $Coro::idle = $Coro::current; |
|
|
171 | # #Coro::schedule; # become idle task, which is implicitly ready |
|
|
172 | # &Event::loop; |
|
|
173 | #} |
|
|
174 | |
|
|
175 | =item unloop([$result]) |
158 | =item unloop([$result]) |
176 | |
159 | |
177 | Same as Event::unloop (provided here for your convinience only). |
160 | Same as Event::unloop (provided here for your convinience only). |
178 | |
161 | |
179 | =cut |
162 | =cut |
180 | |
163 | |
181 | $Coro::idle = new Coro sub { |
164 | $Coro::idle = new Coro sub { |
182 | while () { |
165 | while () { |
|
|
166 | Coro::schedule; |
183 | Event::one_event; # inefficient |
167 | Event::one_event; # inefficient |
184 | Coro::schedule; |
|
|
185 | } |
168 | } |
186 | }; |
169 | }; |
187 | |
170 | |
188 | # provide hooks for Coro::Timer |
171 | # provide hooks for Coro::Timer |
189 | |
172 | |