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

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.133 by root, Sun May 25 03:44:03 2008 UTC vs.
Revision 1.134 by root, Sun May 25 04:44:04 2008 UTC

520C<send> or C<croak> are called. Calling C<recv> inside the callback 520C<send> or C<croak> are called. Calling C<recv> inside the callback
521or at any later time is guaranteed not to block. 521or at any later time is guaranteed not to block.
522 522
523=back 523=back
524 524
525=head3 MAINLOOP EMULATION
526
527Sometimes (often for short test scripts, or even standalone programs
528who only want to use AnyEvent), you I<do> want your program to block
529indefinitely in some event loop.
530
531In that case, you cna use a condition variable like this:
532
533 AnyEvent->condvar->recv;
534
535This has the effect of entering the event loop and looping forever.
536
537Note that usually your program has some exit condition, in which case
538it is better to use the "traditional" approach of storing a condition
539variable, waiting for it, and sending it when the program should exit
540cleanly.
541
542
543=head1 GLOBAL VARIABLES AND FUNCTIONS 525=head1 GLOBAL VARIABLES AND FUNCTIONS
544 526
545=over 4 527=over 4
546 528
547=item $AnyEvent::MODEL 529=item $AnyEvent::MODEL
630 612
631If it doesn't care, it can just "use AnyEvent" and use it itself, or not 613If it doesn't care, it can just "use AnyEvent" and use it itself, or not
632do anything special (it does not need to be event-based) and let AnyEvent 614do anything special (it does not need to be event-based) and let AnyEvent
633decide which implementation to chose if some module relies on it. 615decide which implementation to chose if some module relies on it.
634 616
635If the main program relies on a specific event model. For example, in 617If the main program relies on a specific event model - for example, in
636Gtk2 programs you have to rely on the Glib module. You should load the 618Gtk2 programs you have to rely on the Glib module - you should load the
637event module before loading AnyEvent or any module that uses it: generally 619event module before loading AnyEvent or any module that uses it: generally
638speaking, you should load it as early as possible. The reason is that 620speaking, you should load it as early as possible. The reason is that
639modules might create watchers when they are loaded, and AnyEvent will 621modules might create watchers when they are loaded, and AnyEvent will
640decide on the event model to use as soon as it creates watchers, and it 622decide on the event model to use as soon as it creates watchers, and it
641might chose the wrong one unless you load the correct one yourself. 623might chose the wrong one unless you load the correct one yourself.
642 624
643You can chose to use a rather inefficient pure-perl implementation by 625You can chose to use a pure-perl implementation by loading the
644loading the C<AnyEvent::Impl::Perl> module, which gives you similar 626C<AnyEvent::Impl::Perl> module, which gives you similar behaviour
645behaviour everywhere, but letting AnyEvent chose is generally better. 627everywhere, but letting AnyEvent chose the model is generally better.
628
629=head2 MAINLOOP EMULATION
630
631Sometimes (often for short test scripts, or even standalone programs who
632only want to use AnyEvent), you do not want to run a specific event loop.
633
634In that case, you can use a condition variable like this:
635
636 AnyEvent->condvar->recv;
637
638This has the effect of entering the event loop and looping forever.
639
640Note that usually your program has some exit condition, in which case
641it is better to use the "traditional" approach of storing a condition
642variable somewhere, waiting for it, and sending it when the program should
643exit cleanly.
644
646 645
647=head1 OTHER MODULES 646=head1 OTHER MODULES
648 647
649The following is a non-exhaustive list of additional modules that use 648The following is a non-exhaustive list of additional modules that use
650AnyEvent and can therefore be mixed easily with other AnyEvent modules 649AnyEvent and can therefore be mixed easily with other AnyEvent modules
666 665
667Provides various utility functions for (internet protocol) sockets, 666Provides various utility functions for (internet protocol) sockets,
668addresses and name resolution. Also functions to create non-blocking tcp 667addresses and name resolution. Also functions to create non-blocking tcp
669connections or tcp servers, with IPv6 and SRV record support and more. 668connections or tcp servers, with IPv6 and SRV record support and more.
670 669
670=item L<AnyEvent::DNS>
671
672Provides rich asynchronous DNS resolver capabilities.
673
671=item L<AnyEvent::HTTPD> 674=item L<AnyEvent::HTTPD>
672 675
673Provides a simple web application server framework. 676Provides a simple web application server framework.
674
675=item L<AnyEvent::DNS>
676
677Provides rich asynchronous DNS resolver capabilities.
678 677
679=item L<AnyEvent::FastPing> 678=item L<AnyEvent::FastPing>
680 679
681The fastest ping in the west. 680The fastest ping in the west.
682 681

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines