… | |
… | |
740 | variable itself. Calling C<recv> inside the callback or at any later time |
740 | variable itself. Calling C<recv> inside the callback or at any later time |
741 | is guaranteed not to block. |
741 | is guaranteed not to block. |
742 | |
742 | |
743 | =back |
743 | =back |
744 | |
744 | |
|
|
745 | =head1 SUPPORTED EVENT LOOPS/BACKENDS |
|
|
746 | |
|
|
747 | The available backend classes are (every class has its own manpage): |
|
|
748 | |
|
|
749 | =over 4 |
|
|
750 | |
|
|
751 | =item Backends that are autoprobed when no other event loop can be found. |
|
|
752 | |
|
|
753 | EV is the preferred backend when no other event loop seems to be in |
|
|
754 | use. If EV is not installed, then AnyEvent will try Event, and, failing |
|
|
755 | that, will fall back to its own pure-perl implementation, which is |
|
|
756 | available everywhere as it comes with AnyEvent itself. |
|
|
757 | |
|
|
758 | AnyEvent::Impl::EV based on EV (interface to libev, best choice). |
|
|
759 | AnyEvent::Impl::Event based on Event, very stable, few glitches. |
|
|
760 | AnyEvent::Impl::Perl pure-perl implementation, fast and portable. |
|
|
761 | |
|
|
762 | =item Backends that are transparently being picked up when they are used. |
|
|
763 | |
|
|
764 | These will be used when they are currently loaded when the first watcher |
|
|
765 | is created, in which case it is assumed that the application is using |
|
|
766 | them. This means that AnyEvent will automatically pick the right backend |
|
|
767 | when the main program loads an event module before anything starts to |
|
|
768 | create watchers. Nothing special needs to be done by the main program. |
|
|
769 | |
|
|
770 | AnyEvent::Impl::Glib based on Glib, slow but very stable. |
|
|
771 | AnyEvent::Impl::Tk based on Tk, very broken. |
|
|
772 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
|
|
773 | AnyEvent::Impl::POE based on POE, very slow, some limitations. |
|
|
774 | |
|
|
775 | =item Backends with special needs. |
|
|
776 | |
|
|
777 | Qt requires the Qt::Application to be instantiated first, but will |
|
|
778 | otherwise be picked up automatically. As long as the main program |
|
|
779 | instantiates the application before any AnyEvent watchers are created, |
|
|
780 | everything should just work. |
|
|
781 | |
|
|
782 | AnyEvent::Impl::Qt based on Qt. |
|
|
783 | |
|
|
784 | Support for IO::Async can only be partial, as it is too broken and |
|
|
785 | architecturally limited to even support the AnyEvent API. It also |
|
|
786 | is the only event loop that needs the loop to be set explicitly, so |
|
|
787 | it can only be used by a main program knowing about AnyEvent. See |
|
|
788 | L<AnyEvent::Impl::Async> for the gory details. |
|
|
789 | |
|
|
790 | AnyEvent::Impl::IOAsync based on IO::Async, cannot be autoprobed. |
|
|
791 | |
|
|
792 | =item Event loops that are indirectly supported via other backends. |
|
|
793 | |
|
|
794 | Some event loops can be supported via other modules: |
|
|
795 | |
|
|
796 | There is no direct support for WxWidgets (L<Wx>) or L<Prima>. |
|
|
797 | |
|
|
798 | B<WxWidgets> has no support for watching file handles. However, you can |
|
|
799 | use WxWidgets through the POE adaptor, as POE has a Wx backend that simply |
|
|
800 | polls 20 times per second, which was considered to be too horrible to even |
|
|
801 | consider for AnyEvent. |
|
|
802 | |
|
|
803 | B<Prima> is not supported as nobody seems to be using it, but it has a POE |
|
|
804 | backend, so it can be supported through POE. |
|
|
805 | |
|
|
806 | AnyEvent knows about both L<Prima> and L<Wx>, however, and will try to |
|
|
807 | load L<POE> when detecting them, in the hope that POE will pick them up, |
|
|
808 | in which case everything will be automatic. |
|
|
809 | |
|
|
810 | =back |
|
|
811 | |
745 | =head1 GLOBAL VARIABLES AND FUNCTIONS |
812 | =head1 GLOBAL VARIABLES AND FUNCTIONS |
746 | |
813 | |
747 | =over 4 |
814 | =over 4 |
748 | |
815 | |
749 | =item $AnyEvent::MODEL |
816 | =item $AnyEvent::MODEL |
… | |
… | |
751 | Contains C<undef> until the first watcher is being created. Then it |
818 | Contains C<undef> until the first watcher is being created. Then it |
752 | contains the event model that is being used, which is the name of the |
819 | contains the event model that is being used, which is the name of the |
753 | Perl class implementing the model. This class is usually one of the |
820 | Perl class implementing the model. This class is usually one of the |
754 | C<AnyEvent::Impl:xxx> modules, but can be any other class in the case |
821 | C<AnyEvent::Impl:xxx> modules, but can be any other class in the case |
755 | AnyEvent has been extended at runtime (e.g. in I<rxvt-unicode>). |
822 | AnyEvent has been extended at runtime (e.g. in I<rxvt-unicode>). |
756 | |
|
|
757 | The known classes so far are: |
|
|
758 | |
|
|
759 | AnyEvent::Impl::EV based on EV (an interface to libev, best choice). |
|
|
760 | AnyEvent::Impl::Event based on Event, second best choice. |
|
|
761 | AnyEvent::Impl::Perl pure-perl implementation, fast and portable. |
|
|
762 | AnyEvent::Impl::Glib based on Glib, third-best choice. |
|
|
763 | AnyEvent::Impl::Tk based on Tk, very bad choice. |
|
|
764 | AnyEvent::Impl::Qt based on Qt, cannot be autoprobed (see its docs). |
|
|
765 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
|
|
766 | AnyEvent::Impl::POE based on POE, not generic enough for full support. |
|
|
767 | |
|
|
768 | # warning, support for IO::Async is only partial, as it is too broken |
|
|
769 | # and limited toe ven support the AnyEvent API. See AnyEvent::Impl::Async. |
|
|
770 | AnyEvent::Impl::IOAsync based on IO::Async, cannot be autoprobed (see its docs). |
|
|
771 | |
|
|
772 | There is no support for WxWidgets, as WxWidgets has no support for |
|
|
773 | watching file handles. However, you can use WxWidgets through the |
|
|
774 | POE Adaptor, as POE has a Wx backend that simply polls 20 times per |
|
|
775 | second, which was considered to be too horrible to even consider for |
|
|
776 | AnyEvent. Likewise, other POE backends can be used by AnyEvent by using |
|
|
777 | it's adaptor. |
|
|
778 | |
|
|
779 | AnyEvent knows about L<Prima> and L<Wx> and will try to use L<POE> when |
|
|
780 | autodetecting them. |
|
|
781 | |
823 | |
782 | =item AnyEvent::detect |
824 | =item AnyEvent::detect |
783 | |
825 | |
784 | Returns C<$AnyEvent::MODEL>, forcing autodetection of the event model |
826 | Returns C<$AnyEvent::MODEL>, forcing autodetection of the event model |
785 | if necessary. You should only call this function right before you would |
827 | if necessary. You should only call this function right before you would |
… | |
… | |
965 | no warnings; |
1007 | no warnings; |
966 | use strict qw(vars subs); |
1008 | use strict qw(vars subs); |
967 | |
1009 | |
968 | use Carp; |
1010 | use Carp; |
969 | |
1011 | |
970 | our $VERSION = 4.8; |
1012 | our $VERSION = 4.801; |
971 | our $MODEL; |
1013 | our $MODEL; |
972 | |
1014 | |
973 | our $AUTOLOAD; |
1015 | our $AUTOLOAD; |
974 | our @ISA; |
1016 | our @ISA; |
975 | |
1017 | |
… | |
… | |
1001 | [Event:: => AnyEvent::Impl::Event::], |
1043 | [Event:: => AnyEvent::Impl::Event::], |
1002 | [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl::], |
1044 | [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl::], |
1003 | # everything below here will not be autoprobed |
1045 | # everything below here will not be autoprobed |
1004 | # as the pureperl backend should work everywhere |
1046 | # as the pureperl backend should work everywhere |
1005 | # and is usually faster |
1047 | # and is usually faster |
1006 | [Tk:: => AnyEvent::Impl::Tk::], # crashes with many handles |
|
|
1007 | [Glib:: => AnyEvent::Impl::Glib::], # becomes extremely slow with many watchers |
1048 | [Glib:: => AnyEvent::Impl::Glib::], # becomes extremely slow with many watchers |
1008 | [Event::Lib:: => AnyEvent::Impl::EventLib::], # too buggy |
1049 | [Event::Lib:: => AnyEvent::Impl::EventLib::], # too buggy |
|
|
1050 | [Tk:: => AnyEvent::Impl::Tk::], # crashes with many handles |
|
|
1051 | [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza |
1009 | [Qt:: => AnyEvent::Impl::Qt::], # requires special main program |
1052 | [Qt:: => AnyEvent::Impl::Qt::], # requires special main program |
1010 | [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza |
|
|
1011 | [Wx:: => AnyEvent::Impl::POE::], |
1053 | [Wx:: => AnyEvent::Impl::POE::], |
1012 | [Prima:: => AnyEvent::Impl::POE::], |
1054 | [Prima:: => AnyEvent::Impl::POE::], |
1013 | # IO::Async is just too broken - we would need workaorunds for its |
1055 | # IO::Async is just too broken - we would need workarounds for its |
1014 | # byzantine signal and broken child handling, among others. |
1056 | # byzantine signal and broken child handling, among others. |
1015 | # IO::Async is rather hard to detect, as it doesn't have any |
1057 | # IO::Async is rather hard to detect, as it doesn't have any |
1016 | # obvious default class. |
1058 | # obvious default class. |
1017 | # [IO::Async:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1059 | # [IO::Async:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1018 | # [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1060 | # [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # requires special main program |