… | |
… | |
826 | no warnings; |
826 | no warnings; |
827 | use strict; |
827 | use strict; |
828 | |
828 | |
829 | use Carp; |
829 | use Carp; |
830 | |
830 | |
831 | our $VERSION = 4.2; |
831 | our $VERSION = 4.21; |
832 | our $MODEL; |
832 | our $MODEL; |
833 | |
833 | |
834 | our $AUTOLOAD; |
834 | our $AUTOLOAD; |
835 | our @ISA; |
835 | our @ISA; |
836 | |
836 | |
… | |
… | |
963 | |
963 | |
964 | my $class = shift; |
964 | my $class = shift; |
965 | $class->$func (@_); |
965 | $class->$func (@_); |
966 | } |
966 | } |
967 | |
967 | |
|
|
968 | # utility function to dup a filehandle. this is used by many backends |
|
|
969 | # to support binding more than one watcher per filehandle (they usually |
|
|
970 | # allow only one watcher per fd, so we dup it to get a different one). |
|
|
971 | sub _dupfh($$$$) { |
|
|
972 | my ($poll, $fh, $r, $w) = @_; |
|
|
973 | |
|
|
974 | require Fcntl; |
|
|
975 | |
|
|
976 | # cygwin requires the fh mode to be matching, unix doesn't |
|
|
977 | my ($rw, $mode) = $poll eq "r" ? ($r, "<") |
|
|
978 | : $poll eq "w" ? ($w, ">") |
|
|
979 | : Carp::croak "AnyEvent->io requires poll set to either 'r' or 'w'"; |
|
|
980 | |
|
|
981 | open my $fh2, "$mode&" . fileno $fh |
|
|
982 | or die "cannot dup() filehandle: $!"; |
|
|
983 | |
|
|
984 | # we assume CLOEXEC is already set by perl in all important cases |
|
|
985 | |
|
|
986 | ($fh2, $rw) |
|
|
987 | } |
|
|
988 | |
968 | package AnyEvent::Base; |
989 | package AnyEvent::Base; |
969 | |
990 | |
970 | # default implementation for now and time |
991 | # default implementation for now and time |
971 | |
992 | |
972 | use Time::HiRes (); |
993 | use Time::HiRes (); |
… | |
… | |
1185 | |
1206 | |
1186 | =item C<PERL_ANYEVENT_STRICT> |
1207 | =item C<PERL_ANYEVENT_STRICT> |
1187 | |
1208 | |
1188 | AnyEvent does not do much argument checking by default, as thorough |
1209 | AnyEvent does not do much argument checking by default, as thorough |
1189 | argument checking is very costly. Setting this variable to a true value |
1210 | argument checking is very costly. Setting this variable to a true value |
1190 | will cause AnyEvent to thoroughly check the arguments passed to most |
1211 | will cause AnyEvent to load C<AnyEvent::Strict> and then to thoroughly |
1191 | method calls and croaks if it finds any problems. In other words, enables |
1212 | check the arguments passed to most method calls. If it finds any problems |
|
|
1213 | it will croak. |
|
|
1214 | |
|
|
1215 | In other words, enables "strict" mode. |
|
|
1216 | |
1192 | "strict" mode. Unlike C<use strict> it is definitely recommended ot keep |
1217 | Unlike C<use strict> it is definitely recommended ot keep it off in |
1193 | it off in production. |
1218 | production. |
1194 | |
1219 | |
1195 | =item C<PERL_ANYEVENT_MODEL> |
1220 | =item C<PERL_ANYEVENT_MODEL> |
1196 | |
1221 | |
1197 | This can be used to specify the event model to be used by AnyEvent, before |
1222 | This can be used to specify the event model to be used by AnyEvent, before |
1198 | auto detection and -probing kicks in. It must be a string consisting |
1223 | auto detection and -probing kicks in. It must be a string consisting |