| 1 | package Linux::Event::Stream::_Descriptor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 87 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 87 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 87 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 87 | our $VERSION = '0.105'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 87 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 87 | ▶ | use mro (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 87 | ▶ | use Linux::Event::_SocketConfig (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # Private descriptor storage is isolated here so Stream.pm can remain the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # readable connection-lifecycle implementation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 87 | my %FRAMER_DEFINITION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | my %TLS_DEFINITION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 87 | my %CLASS_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 90 | ▶ | sub declare_framer ($base, $target, $definition) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
declare_framer: called CC=5 SCAR=17.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 90 | ▶ | croak 'a framer may be declared only for a Linux::Event::Stream subclass' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$target eq $base or not $target->isa($base)
MC/DC0%0/2
$target eq $base or not $target->isa($base)
$target eq $base
not $target->isa($base)
Truth table33%1/3
A or not(B)
A= $target eq $baseB= not $target->isa($base)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | if $target eq $base || !$target->isa($base); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | croak "$target already has a Stream descriptor" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 90 | ▶ | if exists $CLASS_DESCRIPTOR{$target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | croak "$target already declares a framer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 90 | ▶ | if exists $FRAMER_DEFINITION{$target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 89 | $FRAMER_DEFINITION{$target} = $definition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 89 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 197 | ▶ | sub _framer_for ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_framer_for: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 197 | for my $package (@{ mro::get_linear_isa($class) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | return $FRAMER_DEFINITION{$package} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 316 | ▶ | if exists $FRAMER_DEFINITION{$package}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 112 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 8 | ▶ | sub declare_tls ($base, $target, $definition) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
declare_tls: called CC=6 SCAR=19.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 8 | ▶ | croak 'TLS may be declared only for a Linux::Event::Stream subclass' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$target eq $base or not $target->isa($base)
MC/DC0%0/2
$target eq $base or not $target->isa($base)
$target eq $base
not $target->isa($base)
Truth table33%1/3
A or not(B)
A= $target eq $baseB= not $target->isa($base)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | if $target eq $base || !$target->isa($base); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | croak "$target already has a Stream descriptor" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | ▶ | if exists $CLASS_DESCRIPTOR{$target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | croak "$target already declares TLS" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 8 | ▶ | if exists $TLS_DEFINITION{$target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 7 | ▶ | croak 'TLS declaration must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | if ref($definition) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | $TLS_DEFINITION{$target} = $definition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 197 | ▶ | sub _tls_for ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tls_for: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 197 | for my $package (@{ mro::get_linear_isa($class) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | return $TLS_DEFINITION{$package} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 405 | ▶ | if exists $TLS_DEFINITION{$package}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 190 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 197 | ▶ | sub _stream_options_for ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_options_for: called CC=20 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | my %option = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | high_watermark => 1_048_576, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | low_watermark => 262_144, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | max_pending_bytes => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | read_size => 65_536, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | read_batch_bytes => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | message_batch_size => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | max_buffer => 8_388_608, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | idle_timeout => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | read_timeout => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | write_timeout => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 197 | map { $_ => undef } Linux::Event::_SocketConfig::names(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 197 | ▶ | if (my $configure = $class->can('stream_options')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 75 | my @configured = $configure->($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 75 | my %configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 75 | ▶ | if (@configured == 1 && ref($configured[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@configured == 1 and ref $configured[0] eq "HASH"
MC/DC100%2/2
@configured == 1 and ref $configured[0] eq "HASH"
@configured == 1
ref $configured[0] eq "HASH"
Truth table100%3/3
A and B
A= @configured == 1B= ref $configured[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | %configured = %{ $configured[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 74 | ▶ | croak "$class stream_options() returned an odd option list" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | if @configured % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 73 | %configured = @configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 74 | my @unknown = grep { !exists $option{$_} } keys %configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 74 | ▶ | croak "$class stream_options() returned unknown options: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | . join(', ', sort @unknown) if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 73 | @option{keys %configured} = values %configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | croak "$class high_watermark must be a non-negative integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 195 | ▶ | if $option{high_watermark} !~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | croak "$class low_watermark must be a non-negative integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 195 | ▶ | if $option{low_watermark} !~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | croak "$class low_watermark must be <= high_watermark" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 195 | ▶ | if $option{low_watermark} > $option{high_watermark}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | croak "$class max_pending_bytes must be a non-negative integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 194 | ▶ | if $option{max_pending_bytes} !~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | croak "$class read_size must be a positive integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 193 | ▶ | if $option{read_size} !~ /\A\d+\z/ || $option{read_size} <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $option{"read_size"} =~ /\A\d+\z/u or $option{"read_size"} <= 0
MC/DC50%1/2
not $option{"read_size"} =~ /\A\d+\z/u or $option{"read_size"} <= 0
not $option{"read_size"} =~ /\A\d+\z/u
$option{"read_size"} <= 0
Truth table66%2/3
not(A) or B
A= not $option{"read_size"} =~ /\A\d+\z/uB= $option{"read_size"} <= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | croak "$class read_batch_bytes must be a non-negative integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 192 | ▶ | if $option{read_batch_bytes} !~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | croak "$class message_batch_size must be a non-negative integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 191 | ▶ | if $option{message_batch_size} !~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | croak "$class max_buffer must be a positive integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 190 | ▶ | if $option{max_buffer} !~ /\A\d+\z/ || $option{max_buffer} <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $option{"max_buffer"} =~ /\A\d+\z/u or $option{"max_buffer"} <= 0
MC/DC0%0/2
not $option{"max_buffer"} =~ /\A\d+\z/u or $option{"max_buffer"} <= 0
not $option{"max_buffer"} =~ /\A\d+\z/u
$option{"max_buffer"} <= 0
Truth table33%1/3
not(A) or B
A= not $option{"max_buffer"} =~ /\A\d+\z/uB= $option{"max_buffer"} <= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 190 | for my $name (qw(idle_timeout read_timeout write_timeout)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | $option{$name} = Linux::Event::Stream::_timeout_value( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 568 | $class, $name, $option{$name}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 189 | for my $name (Linux::Event::_SocketConfig::names()) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | $option{$name} = Linux::Event::_SocketConfig::normalize( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | $class, $name, $option{$name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1505 | ▶ | ) if defined $option{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1504 | ▶ | delete $option{$name} if !defined $option{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 188 | return \%option; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 103031 | ▶ | sub for_class ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
for_class: called CC=23 SCAR=31.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 103031 | ▶ | return $CLASS_DESCRIPTOR{$class} if exists $CLASS_DESCRIPTOR{$class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 198 | ▶ | croak 'Linux::Event::Stream is a base class; construct a Stream subclass' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | if $class eq 'Linux::Event::Stream'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 197 | ▶ | croak "$class is not a Linux::Event::Stream subclass" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | if !$class->isa('Linux::Event::Stream'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 197 | my $framer = _framer_for($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 197 | my $tls = _tls_for($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 197 | my $option = _stream_options_for($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 188 | my %callback = map { $_ => scalar $class->can($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | qw(on_data on_message on_messages on_drain on_eof on_error on_close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | on_ready on_transport_ready configure_socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 188 | ▶ | if ($framer) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | croak "$class read_batch_bytes is available only to raw Streams" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 84 | ▶ | if $option->{read_batch_bytes}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | croak "$class cannot define on_data() when it declares a framer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 83 | ▶ | if $callback{on_data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 82 | ▶ | if ($option->{message_batch_size}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | croak "$class enables message_batch_size but does not define on_messages()" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 18 | ▶ | if !$callback{on_messages}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | croak "$class cannot define both on_message() and on_messages()" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 17 | ▶ | if $callback{on_message}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | croak "$class defines on_messages() without enabling message_batch_size" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 64 | ▶ | if $callback{on_messages}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | croak "$class declares a framer but does not define on_message()" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 63 | ▶ | if !$callback{on_message}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | croak "$class has no framer and must define on_data()" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 104 | ▶ | if !$callback{on_data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | croak "$class defines on_message() but does not declare a framer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 103 | ▶ | if $callback{on_message}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | croak "$class defines on_messages() but does not declare a framer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 103 | ▶ | if $callback{on_messages}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | croak "$class message_batch_size is available only to framed Streams" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 102 | ▶ | if $option->{message_batch_size}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 179 | ▶ | my $native = $framer ? { %{ $framer->{native} } } : { read_mode => 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | my $xs = Linux::Event::Stream::XSDescriptor->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | $option->{read_size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | $option->{read_batch_bytes}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | $option->{message_batch_size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | $option->{high_watermark}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | $option->{low_watermark}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | $option->{max_pending_bytes}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | $option->{max_buffer}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | $native->{read_mode}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | $callback{on_data}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | $callback{on_message}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | $callback{on_messages}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | $callback{on_drain} ? \&Linux::Event::Stream::_xs_drain : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | \&Linux::Event::Stream::_xs_read_eof, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | \&Linux::Event::Stream::_xs_read_error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | \&Linux::Event::Stream::_xs_write_error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | \&Linux::Event::Stream::_xs_output_limit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | \&Linux::Event::Stream::_xs_write_empty, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | \&Linux::Event::Stream::_xs_framing_error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | $native->{delimiter}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | $native->{include_delimiter} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | $native->{max_frame}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | $native->{fixed_size} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | $native->{prefix_bytes} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | $native->{prefix_little} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 179 | ▶ | $native->{include_prefix} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%10/10
$native->{"include_delimiter"} // 0
$native->{"fixed_size"} // 0
$native->{"prefix_bytes"} // 0
$native->{"prefix_little"} // 0
$native->{"include_prefix"} // 0
MC/DC100%1/1
$native->{"include_delimiter"} // 0
$native->{"include_delimiter"}
MC/DC100%1/1
$native->{"fixed_size"} // 0
$native->{"fixed_size"}
MC/DC100%1/1
$native->{"prefix_bytes"} // 0
$native->{"prefix_bytes"}
MC/DC100%1/1
$native->{"prefix_little"} // 0
$native->{"prefix_little"}
MC/DC100%1/1
$native->{"include_prefix"} // 0
$native->{"include_prefix"}
Truth table100%2/2
A
A= $native->{"include_delimiter"}
Truth table100%2/2
A
A= $native->{"fixed_size"}
Truth table100%2/2
A
A= $native->{"prefix_bytes"}
Truth table100%2/2
A
A= $native->{"prefix_little"}
Truth table100%2/2
A
A= $native->{"include_prefix"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 179 | my $descriptor = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | xs => $xs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | options => $option, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | native => $native, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | framer => $framer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | tls => $tls, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | callbacks => \%callback, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 179 | $CLASS_DESCRIPTOR{$class} = $descriptor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 179 | return $descriptor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub clear_cache () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_cache: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | %CLASS_DESCRIPTOR = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 87 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||