… | |
… | |
519 | The callback will be called when the condition becomes "true", i.e. when |
519 | The callback will be called when the condition becomes "true", i.e. when |
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 | |
|
|
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 | |
524 | |
542 | |
525 | =head1 GLOBAL VARIABLES AND FUNCTIONS |
543 | =head1 GLOBAL VARIABLES AND FUNCTIONS |
526 | |
544 | |
527 | =over 4 |
545 | =over 4 |
528 | |
546 | |