AnyEvent
view release on metacpan or search on metacpan
lib/AnyEvent.pm view on Meta::CPAN
}
# free memory only needed for probing
undef @models;
undef @REGISTRY;
push @{"$MODEL\::ISA"}, "AnyEvent::Base";
# now nuke some methods that are overridden by the backend.
# SUPER usage is not allowed in these.
for (qw(time signal child idle)) {
undef &{"AnyEvent::Base::$_"}
if defined &{"$MODEL\::$_"};
}
_isa_set;
# we're officially open!
if ($ENV{PERL_ANYEVENT_STRICT}) {
require AnyEvent::Strict;
}
if ($ENV{PERL_ANYEVENT_DEBUG_WRAP}) {
require AnyEvent::Debug;
AnyEvent::Debug::wrap ($ENV{PERL_ANYEVENT_DEBUG_WRAP});
}
if (length $ENV{PERL_ANYEVENT_DEBUG_SHELL}) {
require AnyEvent::Socket;
require AnyEvent::Debug;
my $shell = $ENV{PERL_ANYEVENT_DEBUG_SHELL};
$shell =~ s/\$\$/$$/g;
my ($host, $service) = AnyEvent::Socket::parse_hostport ($shell);
$AnyEvent::Debug::SHELL = AnyEvent::Debug::shell ($host, $service);
}
# now the anyevent environment is set up as the user told us to, so
# call the actual user code - post detects
(shift @post_detect)->() while @post_detect;
undef @post_detect;
*post_detect = sub(&) {
shift->();
undef
};
$MODEL
}
for my $name (@methods) {
*$name = sub {
detect;
# we use goto because
# a) it makes the thunk more transparent
# b) it allows us to delete the thunk later
goto &{ UNIVERSAL::can AnyEvent => "SUPER::$name" }
};
}
# utility function to dup a filehandle. this is used by many backends
# to support binding more than one watcher per filehandle (they usually
# allow only one watcher per fd, so we dup it to get a different one).
sub _dupfh($$;$$) {
my ($poll, $fh, $r, $w) = @_;
# cygwin requires the fh mode to be matching, unix doesn't
my ($rw, $mode) = $poll eq "r" ? ($r, "<&") : ($w, ">&");
open my $fh2, $mode, $fh
or die "AnyEvent->io: cannot dup() filehandle in mode '$poll': $!,";
# we assume CLOEXEC is already set by perl in all important cases
($fh2, $rw)
}
=head1 SIMPLIFIED AE API
Starting with version 5.0, AnyEvent officially supports a second, much
simpler, API that is designed to reduce the calling, typing and memory
overhead by using function call syntax and a fixed number of parameters.
See the L<AE> manpage for details.
=cut
package AE;
our $VERSION = $AnyEvent::VERSION;
sub _reset() {
eval q{
# fall back to the main API by default - backends and AnyEvent::Base
# implementations can overwrite these.
sub io($$$) {
AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2])
}
sub timer($$$) {
AnyEvent->timer (after => $_[0], interval => $_[1], cb => $_[2])
}
sub signal($$) {
AnyEvent->signal (signal => $_[0], cb => $_[1])
}
sub child($$) {
AnyEvent->child (pid => $_[0], cb => $_[1])
}
sub idle($) {
AnyEvent->idle (cb => $_[0]);
}
sub cv(;&) {
( run in 1.887 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )