… | |
… | |
612 | |
612 | |
613 | If it doesn't care, it can just "use AnyEvent" and use it itself, or not |
613 | If it doesn't care, it can just "use AnyEvent" and use it itself, or not |
614 | do anything special (it does not need to be event-based) and let AnyEvent |
614 | do anything special (it does not need to be event-based) and let AnyEvent |
615 | decide which implementation to chose if some module relies on it. |
615 | decide which implementation to chose if some module relies on it. |
616 | |
616 | |
617 | If the main program relies on a specific event model. For example, in |
617 | If the main program relies on a specific event model - for example, in |
618 | Gtk2 programs you have to rely on the Glib module. You should load the |
618 | Gtk2 programs you have to rely on the Glib module - you should load the |
619 | event module before loading AnyEvent or any module that uses it: generally |
619 | event module before loading AnyEvent or any module that uses it: generally |
620 | speaking, you should load it as early as possible. The reason is that |
620 | speaking, you should load it as early as possible. The reason is that |
621 | modules might create watchers when they are loaded, and AnyEvent will |
621 | modules might create watchers when they are loaded, and AnyEvent will |
622 | decide on the event model to use as soon as it creates watchers, and it |
622 | decide on the event model to use as soon as it creates watchers, and it |
623 | might chose the wrong one unless you load the correct one yourself. |
623 | might chose the wrong one unless you load the correct one yourself. |
624 | |
624 | |
625 | You can chose to use a rather inefficient pure-perl implementation by |
625 | You can chose to use a pure-perl implementation by loading the |
626 | loading the C<AnyEvent::Impl::Perl> module, which gives you similar |
626 | C<AnyEvent::Impl::Perl> module, which gives you similar behaviour |
627 | behaviour everywhere, but letting AnyEvent chose is generally better. |
627 | everywhere, but letting AnyEvent chose the model is generally better. |
|
|
628 | |
|
|
629 | =head2 MAINLOOP EMULATION |
|
|
630 | |
|
|
631 | Sometimes (often for short test scripts, or even standalone programs who |
|
|
632 | only want to use AnyEvent), you do not want to run a specific event loop. |
|
|
633 | |
|
|
634 | In that case, you can use a condition variable like this: |
|
|
635 | |
|
|
636 | AnyEvent->condvar->recv; |
|
|
637 | |
|
|
638 | This has the effect of entering the event loop and looping forever. |
|
|
639 | |
|
|
640 | Note that usually your program has some exit condition, in which case |
|
|
641 | it is better to use the "traditional" approach of storing a condition |
|
|
642 | variable somewhere, waiting for it, and sending it when the program should |
|
|
643 | exit cleanly. |
|
|
644 | |
628 | |
645 | |
629 | =head1 OTHER MODULES |
646 | =head1 OTHER MODULES |
630 | |
647 | |
631 | The following is a non-exhaustive list of additional modules that use |
648 | The following is a non-exhaustive list of additional modules that use |
632 | AnyEvent and can therefore be mixed easily with other AnyEvent modules |
649 | AnyEvent and can therefore be mixed easily with other AnyEvent modules |
… | |
… | |
648 | |
665 | |
649 | Provides various utility functions for (internet protocol) sockets, |
666 | Provides various utility functions for (internet protocol) sockets, |
650 | addresses and name resolution. Also functions to create non-blocking tcp |
667 | addresses and name resolution. Also functions to create non-blocking tcp |
651 | connections or tcp servers, with IPv6 and SRV record support and more. |
668 | connections or tcp servers, with IPv6 and SRV record support and more. |
652 | |
669 | |
|
|
670 | =item L<AnyEvent::DNS> |
|
|
671 | |
|
|
672 | Provides rich asynchronous DNS resolver capabilities. |
|
|
673 | |
653 | =item L<AnyEvent::HTTPD> |
674 | =item L<AnyEvent::HTTPD> |
654 | |
675 | |
655 | Provides a simple web application server framework. |
676 | Provides a simple web application server framework. |
656 | |
|
|
657 | =item L<AnyEvent::DNS> |
|
|
658 | |
|
|
659 | Provides rich asynchronous DNS resolver capabilities. |
|
|
660 | |
677 | |
661 | =item L<AnyEvent::FastPing> |
678 | =item L<AnyEvent::FastPing> |
662 | |
679 | |
663 | The fastest ping in the west. |
680 | The fastest ping in the west. |
664 | |
681 | |
… | |
… | |
707 | no warnings; |
724 | no warnings; |
708 | use strict; |
725 | use strict; |
709 | |
726 | |
710 | use Carp; |
727 | use Carp; |
711 | |
728 | |
712 | our $VERSION = '4.0'; |
729 | our $VERSION = '4.03'; |
713 | our $MODEL; |
730 | our $MODEL; |
714 | |
731 | |
715 | our $AUTOLOAD; |
732 | our $AUTOLOAD; |
716 | our @ISA; |
733 | our @ISA; |
717 | |
734 | |