… | |
… | |
1078 | If you want to sprinkle loads of logging calls around your code, consider |
1078 | If you want to sprinkle loads of logging calls around your code, consider |
1079 | creating a logger callback with the C<AnyEvent::Log::logger> function, |
1079 | creating a logger callback with the C<AnyEvent::Log::logger> function, |
1080 | which can reduce typing, codesize and can reduce the logging overhead |
1080 | which can reduce typing, codesize and can reduce the logging overhead |
1081 | enourmously. |
1081 | enourmously. |
1082 | |
1082 | |
|
|
1083 | =item AnyEvent::fh_block $filehandle |
|
|
1084 | |
|
|
1085 | =item AnyEvent::fh_unblock $filehandle |
|
|
1086 | |
|
|
1087 | Sets blocking or non-blocking behaviour for the given filehandle. |
|
|
1088 | |
1083 | =back |
1089 | =back |
1084 | |
1090 | |
1085 | =head1 WHAT TO DO IN A MODULE |
1091 | =head1 WHAT TO DO IN A MODULE |
1086 | |
1092 | |
1087 | As a module author, you should C<use AnyEvent> and call AnyEvent methods |
1093 | As a module author, you should C<use AnyEvent> and call AnyEvent methods |
… | |
… | |
1353 | # } |
1359 | # } |
1354 | } |
1360 | } |
1355 | |
1361 | |
1356 | if (length $ENV{PERL_ANYEVENT_LOG}) { |
1362 | if (length $ENV{PERL_ANYEVENT_LOG}) { |
1357 | require AnyEvent::Log; # AnyEvent::Log does the thing for us |
1363 | require AnyEvent::Log; # AnyEvent::Log does the thing for us |
|
|
1364 | } |
|
|
1365 | |
|
|
1366 | BEGIN { |
|
|
1367 | *_fh_nonblocking = AnyEvent::WIN32 |
|
|
1368 | ? sub($$) { |
|
|
1369 | ioctl $_[0], 0x8004667e, pack "L", $_[1]; # FIONBIO |
|
|
1370 | } |
|
|
1371 | : sub($$) { |
|
|
1372 | fcntl $_[0], AnyEvent::F_SETFL, $_[1] ? AnyEvent::O_NONBLOCK : 0; |
|
|
1373 | } |
|
|
1374 | ; |
|
|
1375 | } |
|
|
1376 | |
|
|
1377 | sub fh_block($) { |
|
|
1378 | _fh_nonblocking shift, 0 |
|
|
1379 | } |
|
|
1380 | |
|
|
1381 | sub fh_unblock($) { |
|
|
1382 | _fh_nonblocking shift, 1 |
1358 | } |
1383 | } |
1359 | |
1384 | |
1360 | our @models = ( |
1385 | our @models = ( |
1361 | [EV:: => AnyEvent::Impl::EV::], |
1386 | [EV:: => AnyEvent::Impl::EV::], |
1362 | [AnyEvent::Loop:: => AnyEvent::Impl::Perl::], |
1387 | [AnyEvent::Loop:: => AnyEvent::Impl::Perl::], |