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

Comparing Coro/Coro/AnyEvent.pm (file contents):
Revision 1.72 by root, Wed Aug 3 09:43:03 2011 UTC vs.
Revision 1.73 by root, Wed Aug 3 14:52:19 2011 UTC

162use common::sense; 162use common::sense;
163 163
164use Coro; 164use Coro;
165use AnyEvent (); 165use AnyEvent ();
166 166
167our $VERSION = 6.03; 167our $VERSION = 6.04;
168 168
169############################################################################# 169#############################################################################
170# idle handler 170# idle handler
171 171
172our $IDLE; 172our $IDLE;
234 # call the readyhook, in case coroutines were already readied 234 # call the readyhook, in case coroutines were already readied
235 _activity; 235 _activity;
236 } 236 }
237 237
238 # augment condvars 238 # augment condvars
239 239 unshift @AnyEvent::CondVar::ISA, "Coro::AnyEvent::CondVar";
240 *AnyEvent::CondVar::_send = sub {
241 (delete $_[0]{_ae_coro})->ready if $_[0]{_ae_coro};
242 };
243
244 *AnyEvent::CondVar::_wait = sub {
245 do {
246 local $_[0]{_ae_coro} = $Coro::current;
247 Coro::schedule;
248 } until $_[0]{_ae_sent};
249 };
250}; 240};
251 241
252=item Coro::AnyEvent::poll 242=item Coro::AnyEvent::poll
253 243
254This call will block the current thread until the event loop has polled 244This call will block the current thread until the event loop has polled
355 my $w = AE::io $_[0], 1, sub { $cb->(1) }; 345 my $w = AE::io $_[0], 1, sub { $cb->(1) };
356 my $t = defined $_[1] && AE::timer $_[1], 0, sub { $cb->(0) }; 346 my $t = defined $_[1] && AE::timer $_[1], 0, sub { $cb->(0) };
357 Coro::rouse_wait 347 Coro::rouse_wait
358} 348}
359 349
350sub Coro::AnyEvent::CondVar::send {
351 (delete $_[0]{_ae_coro})->ready if $_[0]{_ae_coro};
352
353 AnyEvent::CondVar::Base::send $_[0];
354};
355
356sub Coro::AnyEvent::CondVar::recv {
357 until ($_[0]{_ae_sent}) {
358 local $_[0]{_ae_coro} = $Coro::current;
359 Coro::schedule;
360 }
361
362 AnyEvent::CondVar::Base::recv $_[0];
363};
364
3601; 3651;
361 366
362=back 367=back
363 368
364=head1 IMPLEMENTATION DETAILS 369=head1 IMPLEMENTATION DETAILS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines