sub end {
return if --$_[0]{_ae_counter};
&{ $_[0]{_ae_end_cb} || sub { $_[0]->send } };
}
# undocumented/compatibility with pre-3.4
*broadcast = \&send;
*wait = \&_wait;
=head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE
This is an advanced topic that you do not normally need to use AnyEvent in
a module. This section is only of use to event loop authors who want to
provide AnyEvent compatibility.
If you need to support another event library which isn't directly
supported by AnyEvent, you can supply your own interface to it by
pushing, before the first watcher gets created, the package name of
the event module and the package name of the interface to use onto
C<@AnyEvent::REGISTRY>. You can do that before and even without loading
AnyEvent, so it is reasonably cheap.
Example:
push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::];
This tells AnyEvent to (literally) use the C<urxvt::anyevent::>
package/class when it finds the C<urxvt> package/module is already loaded.
When AnyEvent is loaded and asked to find a suitable event model, it
will first check for the presence of urxvt by trying to C<use> the
C<urxvt::anyevent> module.
The class should provide implementations for all watcher types. See
L<AnyEvent::Impl::EV> (source code), L<AnyEvent::Impl::Glib> (Source code)
and so on for actual examples. Use C<perldoc -m AnyEvent::Impl::Glib> to
see the sources.
If you don't provide C<signal> and C<child> watchers than AnyEvent will
provide suitable (hopefully) replacements.
The above example isn't fictitious, the I<rxvt-unicode> (a.k.a. urxvt)
terminal emulator uses the above line as-is. An interface isn't included
in AnyEvent because it doesn't make sense outside the embedded interpreter
inside I<rxvt-unicode>, and it is updated and maintained as part of the
I<rxvt-unicode> distribution.
I<rxvt-unicode> also cheats a bit by not providing blocking access to
condition variables: code blocking while waiting for a condition will
C<die>. This still works with most modules/usages, and blocking calls must
not be done in an interactive application, so it makes sense.
=head1 ENVIRONMENT VARIABLES
The following environment variables are used by this module:
=over 4
=item C<PERL_ANYEVENT_VERBOSE>
By default, AnyEvent will be completely silent except in fatal
conditions. You can set this environment variable to make AnyEvent more
talkative.
When set to C<1> or higher, causes AnyEvent to warn about unexpected
conditions, such as not being able to load the event model specified by
C<PERL_ANYEVENT_MODEL>.
When set to C<2> or higher, cause AnyEvent to report to STDERR which event
model it chooses.
=item C<PERL_ANYEVENT_MODEL>
This can be used to specify the event model to be used by AnyEvent, before
auto detection and -probing kicks in. It must be a string consisting
entirely of ASCII letters. The string C<AnyEvent::Impl::> gets prepended
and the resulting module name is loaded and if the load was successful,
used as event model. If it fails to load AnyEvent will proceed with
auto detection and -probing.
This functionality might change in future versions.
For example, to force the pure perl model (L<AnyEvent::Impl::Perl>) you
could start your program like this:
PERL_ANYEVENT_MODEL=Perl perl ...
=item C<PERL_ANYEVENT_PROTOCOLS>
Used by both L<AnyEvent::DNS> and L<AnyEvent::Socket> to determine preferences
for IPv4 or IPv6. The default is unspecified (and might change, or be the result
of auto probing).
Must be set to a comma-separated list of protocols or address families,
current supported: C<ipv4> and C<ipv6>. Only protocols mentioned will be
used, and preference will be given to protocols mentioned earlier in the
list.
This variable can effectively be used for denial-of-service attacks
=12= |