… | |
… | |
520 | C<send> or C<croak> are called. Calling C<recv> inside the callback |
520 | C<send> or C<croak> are called. Calling C<recv> inside the callback |
521 | or at any later time is guaranteed not to block. |
521 | or at any later time is guaranteed not to block. |
522 | |
522 | |
523 | =back |
523 | =back |
524 | |
524 | |
|
|
525 | =head3 MAINLOOP EMULATION |
|
|
526 | |
|
|
527 | Sometimes (often for short test scripts, or even standalone programs |
|
|
528 | who only want to use AnyEvent), you I<do> want your program to block |
|
|
529 | indefinitely in some event loop. |
|
|
530 | |
|
|
531 | In that case, you cna use a condition variable like this: |
|
|
532 | |
|
|
533 | AnyEvent->condvar->recv; |
|
|
534 | |
|
|
535 | This has the effect of entering the event loop and looping forever. |
|
|
536 | |
|
|
537 | Note that usually your program has some exit condition, in which case |
|
|
538 | it is better to use the "traditional" approach of storing a condition |
|
|
539 | variable, waiting for it, and sending it when the program should exit |
|
|
540 | cleanly. |
|
|
541 | |
|
|
542 | |
525 | =head1 GLOBAL VARIABLES AND FUNCTIONS |
543 | =head1 GLOBAL VARIABLES AND FUNCTIONS |
526 | |
544 | |
527 | =over 4 |
545 | =over 4 |
528 | |
546 | |
529 | =item $AnyEvent::MODEL |
547 | =item $AnyEvent::MODEL |
… | |
… | |
707 | no warnings; |
725 | no warnings; |
708 | use strict; |
726 | use strict; |
709 | |
727 | |
710 | use Carp; |
728 | use Carp; |
711 | |
729 | |
712 | our $VERSION = '4.0'; |
730 | our $VERSION = '4.03'; |
713 | our $MODEL; |
731 | our $MODEL; |
714 | |
732 | |
715 | our $AUTOLOAD; |
733 | our $AUTOLOAD; |
716 | our @ISA; |
734 | our @ISA; |
717 | |
735 | |