| 1 | package IPC::Manager::Role::Service::Select; | ||||||||||||||||||||||||||||
| 2 | 209 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 209 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 209 | our $VERSION = '0.000036'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # Not included in role: | ||||||||||||||||||||||||||||
| 8 | 209 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 209 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 209 | requires qw{ | |||||||||||||||||||||||||||
| 13 | select_handles | ||||||||||||||||||||||||||||
| 14 | }; | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | sub clear_serviceselect_fields { | ||||||||||||||||||||||||||||
| 17 | 445 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
clear_serviceselect_fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 445 | delete $self->{_SELECT}; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Returns true when the underlying client multiplexes a handle set that may | ||||||||||||||||||||||||||||
| 22 | # change during normal operation (e.g. accepted SOCK_STREAM connections). | ||||||||||||||||||||||||||||
| 23 | # Defaults to consulting the client; consumers that don't have a client | ||||||||||||||||||||||||||||
| 24 | # accessor get the safe answer (false). | ||||||||||||||||||||||||||||
| 25 | sub have_dynamic_handles_for_select { | ||||||||||||||||||||||||||||
| 26 | 767 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
have_dynamic_handles_for_select: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 767 | ▶ | return 0 unless $self->can('client'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 763 | ▶ | my $client = $self->client or return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 763 | ▶ | return 0 unless $client->can('have_dynamic_handles_for_select'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 532 | ▶ | return $client->have_dynamic_handles_for_select ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub select { | ||||||||||||||||||||||||||||
| 34 | 767 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
select: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 767 | my $dynamic = $self->have_dynamic_handles_for_select; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 767 | ▶ | return $self->{_SELECT} if !$dynamic && exists $self->{_SELECT}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $dynamic and exists $self->{"_SELECT"}
MC/DC100%2/2
not $dynamic and exists $self->{"_SELECT"}
not $dynamic
exists $self->{"_SELECT"}
Truth table100%3/3
not(A) and B
A= not $dynamicB= exists $self->{"_SELECT"}
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 299 | my @handles = $self->select_handles; | |||||||||||||||||||||||||||
| 41 | 299 | ▶ | unless (@handles) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 123 | ▶ | $self->{_SELECT} = undef unless $dynamic; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 123 | return undef; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 176 | require IO::Select; | |||||||||||||||||||||||||||
| 47 | 176 | my $s = IO::Select->new; | |||||||||||||||||||||||||||
| 48 | 176 | $s->add(@handles); | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 176 | ▶ | $self->{_SELECT} = $s unless $dynamic; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 176 | return $s; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # Build a fresh IO::Select for the client's writable handles, or | ||||||||||||||||||||||||||||
| 55 | # return undef when no peer has a backlog. Built fresh per call | ||||||||||||||||||||||||||||
| 56 | # because the writable-handle set tracks the outbox, which is | ||||||||||||||||||||||||||||
| 57 | # transient by design. | ||||||||||||||||||||||||||||
| 58 | sub select_write { | ||||||||||||||||||||||||||||
| 59 | 374 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
select_write: called CC=3 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | 374 | my $client = $self->client; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 374 | ▶ | return undef unless $client->have_writable_handles; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | my @handles = $client->writable_handles; | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | return undef unless @handles; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | require IO::Select; | |||||||||||||||||||||||||||
| 68 | 0 | my $s = IO::Select->new; | |||||||||||||||||||||||||||
| 69 | 0 | $s->add(@handles); | |||||||||||||||||||||||||||
| 70 | 0 | return $s; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 209 | 1; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||