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.135 by root, Sun May 25 04:49:01 2008 UTC vs.
Revision 1.139 by root, Mon May 26 06:04:38 2008 UTC

731no warnings; 731no warnings;
732use strict; 732use strict;
733 733
734use Carp; 734use Carp;
735 735
736our $VERSION = '4.03'; 736our $VERSION = '4.04';
737our $MODEL; 737our $MODEL;
738 738
739our $AUTOLOAD; 739our $AUTOLOAD;
740our @ISA; 740our @ISA;
741 741
742our @REGISTRY; 742our @REGISTRY;
743 743
744our $WIN32;
745
746BEGIN {
747 my $win32 = ! ! ($^O =~ /mswin32/i);
748 eval "sub WIN32(){ $win32 }";
749}
750
744our $verbose = $ENV{PERL_ANYEVENT_VERBOSE}*1; 751our $verbose = $ENV{PERL_ANYEVENT_VERBOSE}*1;
745 752
746our %PROTOCOL; # (ipv4|ipv6) => (1|2) 753our %PROTOCOL; # (ipv4|ipv6) => (1|2), higher numbers are preferred
747 754
748{ 755{
749 my $idx; 756 my $idx;
750 $PROTOCOL{$_} = ++$idx 757 $PROTOCOL{$_} = ++$idx
758 for reverse split /\s*,\s*/,
751 for split /\s*,\s*/, $ENV{PERL_ANYEVENT_PROTOCOLS} || "ipv4,ipv6"; 759 $ENV{PERL_ANYEVENT_PROTOCOLS} || "ipv4,ipv6";
760}
761
762sub import {
763 shift;
764 return unless @_;
765
766 my $pkg = caller;
767
768 no strict 'refs';
769
770 for (@_) {
771 *{"$pkg\::WIN32"} = *WIN32 if $_ eq "WIN32";
772 }
752} 773}
753 774
754my @models = ( 775my @models = (
755 [EV:: => AnyEvent::Impl::EV::], 776 [EV:: => AnyEvent::Impl::EV::],
756 [Event:: => AnyEvent::Impl::Event::], 777 [Event:: => AnyEvent::Impl::Event::],
792} 813}
793 814
794sub detect() { 815sub detect() {
795 unless ($MODEL) { 816 unless ($MODEL) {
796 no strict 'refs'; 817 no strict 'refs';
818 local $SIG{__DIE__};
797 819
798 if ($ENV{PERL_ANYEVENT_MODEL} =~ /^([a-zA-Z]+)$/) { 820 if ($ENV{PERL_ANYEVENT_MODEL} =~ /^([a-zA-Z]+)$/) {
799 my $model = "AnyEvent::Impl::$1"; 821 my $model = "AnyEvent::Impl::$1";
800 if (eval "require $model") { 822 if (eval "require $model") {
801 $MODEL = $model; 823 $MODEL = $model;
924 or Carp::croak "required option 'pid' is missing"; 946 or Carp::croak "required option 'pid' is missing";
925 947
926 $PID_CB{$pid}{$arg{cb}} = $arg{cb}; 948 $PID_CB{$pid}{$arg{cb}} = $arg{cb};
927 949
928 unless ($WNOHANG) { 950 unless ($WNOHANG) {
929 $WNOHANG = eval { require POSIX; &POSIX::WNOHANG } || 1; 951 $WNOHANG = eval { local $SIG{__DIE__}; require POSIX; &POSIX::WNOHANG } || 1;
930 } 952 }
931 953
932 unless ($CHLD_W) { 954 unless ($CHLD_W) {
933 $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_sigchld); 955 $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_sigchld);
934 # child could be a zombie already, so make at least one round 956 # child could be a zombie already, so make at least one round

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines