| 1 | package POE::Component::DirWatch::Role::AIO; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | our $VERSION = "0.300004"; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use POE; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use IO::AIO qw/2/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use POE::Component::AIO { no_auto_export => 1, no_auto_bootstrap => 1 }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Path::Class qw(file dir); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | has aio => ( | ||||||||||||||||||||||||||||
| 12 | is => 'ro', | ||||||||||||||||||||||||||||
| 13 | isa => 'POE::Component::AIO', | ||||||||||||||||||||||||||||
| 14 | required => 1, | ||||||||||||||||||||||||||||
| 15 | clearer => 'clear_aio', | ||||||||||||||||||||||||||||
| 16 | 3 | ▶ | default => sub { POE::Component::AIO->new } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 4 | ); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 3 | ▶ | after _start => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.0
| |||||||||||||||||||||||||||||
| 20 | 3 | my $self = $_[OBJECT]; | |||||||||||||||||||||||||||
| 21 | 9 | ▶ | my $aio_cb = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=31.7
| |||||||||||||||||||||||||||||
| 22 | 9 | my ($kernel, $dirs, $nondirs) = @_[KERNEL, ARG0, ARG1]; | |||||||||||||||||||||||||||
| 23 | 9 | ▶ | my $filter = $self->has_filter ? $self->filter : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 9 | ▶ | if( $self->has_dir_callback ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 0 | foreach my $child (@$dirs){ | |||||||||||||||||||||||||||
| 26 | 0 | $child = dir($self->directory, $child); | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | next if ref $filter && !$filter->($child); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $filter and not &$filter($child)
MC/DC0%0/2
ref $filter and not &$filter($child)
ref $filter
not &$filter($child)
Truth table0%0/3
A and not(B)
A= ref $filterB= not &$filter($child)
| |||||||||||||||||||||||||||||
| 28 | 0 | $kernel->yield(dir_callback => $child); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 9 | ▶ | if( $self->has_file_callback ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 9 | foreach my $child (@$nondirs){ | |||||||||||||||||||||||||||
| 33 | 14 | $child = file($self->directory, $child); | |||||||||||||||||||||||||||
| 34 | 14 | ▶ | next if ref $filter && !$filter->($child); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $filter and not &$filter($child)
MC/DC0%0/2
ref $filter and not &$filter($child)
ref $filter
not &$filter($child)
Truth table33%1/3
A and not(B)
A= ref $filterB= not &$filter($child)
| |||||||||||||||||||||||||||||
| 35 | 14 | $poe_kernel->yield(file_callback => $child); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 9 | $self->next_poll( $kernel->delay_set(poll => $self->interval) ); | |||||||||||||||||||||||||||
| 39 | 3 | }; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 3 | $_[KERNEL]->state(aio_callback => $aio_cb); | |||||||||||||||||||||||||||
| 42 | 4 | }; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 9 | ▶ | around _poll => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | 9 | my $super = shift; | |||||||||||||||||||||||||||
| 46 | 9 | my ($self, $kernel) = @_[OBJECT, KERNEL]; | |||||||||||||||||||||||||||
| 47 | 9 | $self->clear_next_poll; | |||||||||||||||||||||||||||
| 48 | 9 | my $dir = $self->directory->stringify; | |||||||||||||||||||||||||||
| 49 | 9 | aio_scandir $dir, 0, $self->aio->postback('aio_callback'); | |||||||||||||||||||||||||||
| 50 | 4 | }; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 3 | ▶ | before _shutdown => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 3 | my ($self, $kernel) = @_[OBJECT, KERNEL]; | |||||||||||||||||||||||||||
| 54 | 3 | $kernel->state('aio_callback'); | |||||||||||||||||||||||||||
| 55 | 3 | $self->aio->shutdown; | |||||||||||||||||||||||||||
| 56 | 3 | $self->clear_aio; | |||||||||||||||||||||||||||
| 57 | 4 | }; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__; | ||||||||||||||||||||||||||||