| 1 | =head1 NAME | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | AnyEvent::AIO - truly asynchronous file and directory I/O | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | use AnyEvent::AIO; | ||||||||||||||||||||
| 8 | use IO::AIO; | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | # can now use any of the aio requests your IO::AIO module supports | ||||||||||||||||||||
| 11 | # as long as you use an event loop supported by AnyEvent. | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | This module is an L<AnyEvent> user, you need to make sure that you use and | ||||||||||||||||||||
| 16 | run a supported event loop. | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | Loading this module will install the necessary magic to seamlessly | ||||||||||||||||||||
| 19 | integrate L<IO::AIO> into L<AnyEvent>, i.e. you no longer need to concern | ||||||||||||||||||||
| 20 | yourself with calling C<IO::AIO::poll_cb> or any of that stuff (you still | ||||||||||||||||||||
| 21 | can, but this module will do it in case you don't). | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | The AnyEvent watcher can be disabled by executing C<undef | ||||||||||||||||||||
| 24 | $AnyEvent::AIO::WATCHER>. Please notify the author of when and why you | ||||||||||||||||||||
| 25 | think this was necessary. | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | =cut | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | package AnyEvent::AIO; | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | 1 | ▶ | no warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 1 | ▶ | use AnyEvent (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 35 | 1 | ▶ | use IO::AIO (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 1 | ▶ | use base Exporter::; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 1 | our $VERSION = '1.1'; | |||||||||||||||||||
| 40 | 1 | our $WATCHER; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | my $guard = AnyEvent::post_detect { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 43 | 0 | $WATCHER = AnyEvent->io (fh => IO::AIO::poll_fileno, poll => 'r', cb => \&IO::AIO::poll_cb); | |||||||||||||||||||
| 44 | 1 | }; | |||||||||||||||||||
| 45 | 1 | ▶ | $WATCHER ||= $guard; | ||||||||||||||||||
|
Condition33%1/3
$AnyEvent::AIO::WATCHER ||= $guard
MC/DC0%0/2
$AnyEvent::AIO::WATCHER ||= $guard
$AnyEvent::AIO::WATCHER
$guard
Truth table33%1/3
A ||= B
A= $AnyEvent::AIO::WATCHERB= $guard
| |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 1 | IO::AIO::_on_next_submit \&AnyEvent::detect; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head1 SEE ALSO | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | L<AnyEvent>, L<Coro::AIO> (for a more natural syntax). | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | =head1 AUTHOR | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | Marc Lehmann <schmorp@schmorp.de> | ||||||||||||||||||||
| 56 | http://home.schmorp.de/ | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | =cut | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 1 | 1 | |||||||||||||||||||