| 1 | package POE::Wheel::ReadWrite; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 27 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 27 | ▶ | use vars qw($VERSION @ISA); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 27 | $VERSION = '1.370'; # NOTE - Should be #.### (three decimal places) | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 27 | ▶ | use Carp qw( croak carp ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 27 | ▶ | use POE qw(Wheel Driver::SysRW Filter::Line); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 27 | push @ISA, qw(POE::Wheel); | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | # Offsets into $self. | ||||||||||||||||||||||||||||||||||||||||||
| 13 | sub HANDLE_INPUT () { 0 } | ||||||||||||||||||||||||||||||||||||||||||
| 14 | sub HANDLE_OUTPUT () { 1 } | ||||||||||||||||||||||||||||||||||||||||||
| 15 | sub FILTER_INPUT () { 2 } | ||||||||||||||||||||||||||||||||||||||||||
| 16 | sub FILTER_OUTPUT () { 3 } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | sub DRIVER_BOTH () { 4 } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | sub EVENT_INPUT () { 5 } | ||||||||||||||||||||||||||||||||||||||||||
| 19 | sub EVENT_ERROR () { 6 } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | sub EVENT_FLUSHED () { 7 } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | sub WATERMARK_WRITE_MARK_HIGH () { 8 } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | sub WATERMARK_WRITE_MARK_LOW () { 9 } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | sub WATERMARK_WRITE_EVENT_HIGH () { 10 } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | sub WATERMARK_WRITE_EVENT_LOW () { 11 } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | sub WATERMARK_WRITE_STATE () { 12 } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | sub DRIVER_BUFFERED_OUT_OCTETS () { 13 } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | sub STATE_WRITE () { 14 } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | sub STATE_READ () { 15 } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | sub UNIQUE_ID () { 16 } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | sub AUTOFLUSH () { 17 } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub CRIMSON_SCOPE_HACK ($) { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CRIMSON_SCOPE_HACK: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 158 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=30 SCAR=34.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 158 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 158 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 158 | ▶ | croak "wheels no longer require a kernel reference as their first parameter" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ and ref $_[0] eq "POE::Kernel"
MC/DC100%2/2
@_ and ref $_[0] eq "POE::Kernel"
@_
ref $_[0] eq "POE::Kernel"
Truth table100%3/3
A and B
A= @_B= ref $_[0] eq "POE::Kernel"
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | if (@_ && (ref($_[0]) eq 'POE::Kernel')); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 156 | ▶ | croak "$type requires a working Kernel" unless defined $poe_kernel; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 156 | my ($in_handle, $out_handle); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 156 | ▶ | if (defined $params{Handle}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | carp "Ignoring InputHandle parameter (Handle parameter takes precedence)" | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 148 | ▶ | if defined $params{InputHandle}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | carp "Ignoring OutputHandle parameter (Handle parameter takes precedence)" | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 148 | ▶ | if defined $params{OutputHandle}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 148 | $in_handle = $out_handle = delete $params{Handle}; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 54 | croak "Handle or InputHandle required" | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 8 | ▶ | unless defined $params{InputHandle}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | croak "Handle or OutputHandle required" | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | ▶ | unless defined $params{OutputHandle}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | $in_handle = delete $params{InputHandle}; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | $out_handle = delete $params{OutputHandle}; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 152 | my ($in_filter, $out_filter); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 152 | ▶ | if (defined $params{Filter}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | carp "Ignoring InputFilter parameter (Filter parameter takes precedence)" | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 109 | ▶ | if (defined $params{InputFilter}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | carp "Ignoring OutputFilter parameter (Filter parameter takes precedence)" | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 109 | ▶ | if (defined $params{OutputFilter}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 109 | $in_filter = $out_filter = delete $params{Filter}; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 43 | $in_filter = delete $params{InputFilter}; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 43 | $out_filter = delete $params{OutputFilter}; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | # If neither Filter, InputFilter or OutputFilter is defined, then | ||||||||||||||||||||||||||||||||||||||||||
| 75 | # they default to POE::Filter::Line. | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 43 | ▶ | unless (defined $in_filter and defined $out_filter) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $in_filter and defined $out_filter
MC/DC0%0/2
defined $in_filter and defined $out_filter
defined $in_filter
defined $out_filter
Truth table33%1/3
A and B
A= defined $in_filterB= defined $out_filter
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 43 | my $new_filter = POE::Filter::Line->new(); | |||||||||||||||||||||||||||||||||||||||||
| 78 | 43 | ▶ | $in_filter = $new_filter unless defined $in_filter; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 43 | ▶ | $out_filter = $new_filter unless defined $out_filter; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 152 | my $driver = delete $params{Driver}; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 152 | ▶ | $driver = POE::Driver::SysRW->new() unless defined $driver; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 152 | { my $mark_errors = 0; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 152 | ▶ | if (defined($params{HighMark}) xor defined($params{LowMark})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%4/4
defined $params{"HighMark"} xor defined $params{"LowMark"}
MC/DC100%2/2
defined $params{"HighMark"} xor defined $params{"LowMark"}
defined $params{"HighMark"}
defined $params{"LowMark"}
Truth table100%4/4
A xor B
A= defined $params{"HighMark"}B= defined $params{"LowMark"}
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | carp "HighMark and LowMark parameters require each-other"; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | $mark_errors++; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # Then they both exist, and they must be checked. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | elsif (defined $params{HighMark}) { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 12 | ▶ | unless (defined($params{HighMark}) and defined($params{LowMark})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $params{"HighMark"} and defined $params{"LowMark"}
MC/DC0%0/2
defined $params{"HighMark"} and defined $params{"LowMark"}
defined $params{"HighMark"}
defined $params{"LowMark"}
Truth table33%1/3
A and B
A= defined $params{"HighMark"}B= defined $params{"LowMark"}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | carp "HighMark and LowMark parameters must both be defined"; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $mark_errors++; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 12 | ▶ | unless (($params{HighMark} > 0) and ($params{LowMark} > 0)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$params{"HighMark"} > 0 and $params{"LowMark"} > 0
MC/DC100%2/2
$params{"HighMark"} > 0 and $params{"LowMark"} > 0
$params{"HighMark"} > 0
$params{"LowMark"} > 0
Truth table100%3/3
A and B
A= $params{"HighMark"} > 0B= $params{"LowMark"} > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 6 | carp "HighMark and LowMark parameters must be above 0"; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 6 | $mark_errors++; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 152 | ▶ | if (defined $params{HighEvent} and not defined $params{HighMark}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $params{"HighEvent"} and not defined $params{"HighMark"}
MC/DC100%2/2
defined $params{"HighEvent"} and not defined $params{"HighMark"}
defined $params{"HighEvent"}
not defined $params{"HighMark"}
Truth table100%3/3
A and not(B)
A= defined $params{"HighEvent"}B= not defined $params{"HighMark"}
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 6 | carp "HighEvent requires a corresponding HighMark"; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 6 | $mark_errors++; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 152 | ▶ | if (defined($params{LowMark}) xor defined($params{LowEvent})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%4/4
defined $params{"LowMark"} xor defined $params{"LowEvent"}
MC/DC100%2/2
defined $params{"LowMark"} xor defined $params{"LowEvent"}
defined $params{"LowMark"}
defined $params{"LowEvent"}
Truth table100%4/4
A xor B
A= defined $params{"LowMark"}B= defined $params{"LowEvent"}
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | carp "LowMark and LowEvent parameters require each-other"; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 8 | $mark_errors++; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 152 | ▶ | croak "Water mark errors" if $mark_errors; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | my $self = bless [ | ||||||||||||||||||||||||||||||||||||||||||
| 114 | $in_handle, # HANDLE_INPUT | ||||||||||||||||||||||||||||||||||||||||||
| 115 | $out_handle, # HANDLE_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||
| 116 | $in_filter, # FILTER_INPUT | ||||||||||||||||||||||||||||||||||||||||||
| 117 | $out_filter, # FILTER_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||
| 118 | $driver, # DRIVER_BOTH | ||||||||||||||||||||||||||||||||||||||||||
| 119 | delete $params{InputEvent}, # EVENT_INPUT | ||||||||||||||||||||||||||||||||||||||||||
| 120 | delete $params{ErrorEvent}, # EVENT_ERROR | ||||||||||||||||||||||||||||||||||||||||||
| 121 | delete $params{FlushedEvent}, # EVENT_FLUSHED | ||||||||||||||||||||||||||||||||||||||||||
| 122 | # Water marks. | ||||||||||||||||||||||||||||||||||||||||||
| 123 | delete $params{HighMark}, # WATERMARK_WRITE_MARK_HIGH | ||||||||||||||||||||||||||||||||||||||||||
| 124 | delete $params{LowMark}, # WATERMARK_WRITE_MARK_LOW | ||||||||||||||||||||||||||||||||||||||||||
| 125 | delete $params{HighEvent}, # WATERMARK_WRITE_EVENT_HIGH | ||||||||||||||||||||||||||||||||||||||||||
| 126 | delete $params{LowEvent}, # WATERMARK_WRITE_EVENT_LOW | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0, # WATERMARK_WRITE_STATE | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # Driver statistics. | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0, # DRIVER_BUFFERED_OUT_OCTETS | ||||||||||||||||||||||||||||||||||||||||||
| 130 | # Dynamic state names. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | undef, # STATE_WRITE | ||||||||||||||||||||||||||||||||||||||||||
| 132 | undef, # STATE_READ | ||||||||||||||||||||||||||||||||||||||||||
| 133 | # Unique ID. | ||||||||||||||||||||||||||||||||||||||||||
| 134 | &POE::Wheel::allocate_wheel_id(), # UNIQUE_ID | ||||||||||||||||||||||||||||||||||||||||||
| 135 | delete $params{AutoFlush}, # AUTOFLUSH | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 134 | ], $type; | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 134 | ▶ | if (scalar keys %params) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | carp( | |||||||||||||||||||||||||||||||||||||||||
| 140 | "unknown parameters in $type constructor call: ", | ||||||||||||||||||||||||||||||||||||||||||
| 141 | join(', ', keys %params) | ||||||||||||||||||||||||||||||||||||||||||
| 142 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 134 | $self->_define_read_state(); | |||||||||||||||||||||||||||||||||||||||||
| 146 | 132 | $self->_define_write_state(); | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 132 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # Redefine the select-write handler. This uses stupid closure tricks | ||||||||||||||||||||||||||||||||||||||||||
| 153 | # to prevent keeping extra references to $self around. | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 136 | ▶ | sub _define_write_state { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_define_write_state: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 136 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | # Read-only members. If any of these change, then the write state | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # is invalidated and needs to be redefined. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 136 | my $driver = $self->[DRIVER_BOTH]; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 136 | my $high_mark = $self->[WATERMARK_WRITE_MARK_HIGH]; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 136 | my $low_mark = $self->[WATERMARK_WRITE_MARK_LOW]; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 136 | my $event_error = \$self->[EVENT_ERROR]; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 136 | my $event_flushed = \$self->[EVENT_FLUSHED]; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 136 | my $event_high = \$self->[WATERMARK_WRITE_EVENT_HIGH]; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 136 | my $event_low = \$self->[WATERMARK_WRITE_EVENT_LOW]; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 136 | my $unique_id = $self->[UNIQUE_ID]; | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | # Read/write members. These are done by reference, to avoid pushing | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # $self into the anonymous sub. Extra copies of $self are bad and | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # can prevent wheels from destructing properly. | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 136 | my $is_in_high_water_state = \$self->[WATERMARK_WRITE_STATE]; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 136 | my $driver_buffered_out_octets = \$self->[DRIVER_BUFFERED_OUT_OCTETS]; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | # Register the select-write handler. | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | $poe_kernel->state( | ||||||||||||||||||||||||||||||||||||||||||
| 178 | $self->[STATE_WRITE] = ref($self) . "($unique_id) -> select write", | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 217 | ▶ | sub { # prevents SEGV | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=29.0
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 217 | 0 && CRIMSON_SCOPE_HACK('<'); | |||||||||||||||||||||||||||||||||||||||||
| 181 | # subroutine starts here | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 217 | my ($k, $me, $handle) = @_[KERNEL, SESSION, ARG0]; | |||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 217 | $$driver_buffered_out_octets = $driver->flush($handle); | |||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | # When you can't write, nothing else matters. | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 217 | ▶ | if ($!) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | $$event_error && $k->call( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | $me, $$event_error, 'write', ($!+0), $!, $unique_id | ||||||||||||||||||||||||||||||||||||||||||
| 190 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $k->select_write($handle); | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | # Could write, or perhaps couldn't but only because the | ||||||||||||||||||||||||||||||||||||||||||
| 195 | # filehandle's buffer is choked. | ||||||||||||||||||||||||||||||||||||||||||
| 196 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | # In high water state? Check for low water. High water | ||||||||||||||||||||||||||||||||||||||||||
| 199 | # state will never be set if $event_low is undef, so don't | ||||||||||||||||||||||||||||||||||||||||||
| 200 | # bother checking its definedness here. | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 217 | ▶ | if ($$is_in_high_water_state) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | ▶ | if ( $$driver_buffered_out_octets <= $low_mark ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | $$is_in_high_water_state = 0; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | ▶ | $k->call( $me, $$event_low, $unique_id ) if defined $$event_low; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | # Not in high water state. Check for high water. Needs to | ||||||||||||||||||||||||||||||||||||||||||
| 209 | # also check definedness of $$driver_buffered_out_octets. | ||||||||||||||||||||||||||||||||||||||||||
| 210 | # Although we know this ahead of time and could probably | ||||||||||||||||||||||||||||||||||||||||||
| 211 | # optimize it away with a second state definition, it would | ||||||||||||||||||||||||||||||||||||||||||
| 212 | # be best to wait until ReadWrite stabilizes. That way | ||||||||||||||||||||||||||||||||||||||||||
| 213 | # there will be only half as much code to maintain. | ||||||||||||||||||||||||||||||||||||||||||
| 214 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$high_mark and $$driver_buffered_out_octets >= $high_mark
MC/DC0%0/2
$high_mark and $$driver_buffered_out_octets >= $high_mark
$high_mark
$$driver_buffered_out_octets >= $high_mark
Truth table66%2/3
A and B
A= $high_markB= $$driver_buffered_out_octets >= $high_mark
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | $high_mark and | ||||||||||||||||||||||||||||||||||||||||||
| 216 | ( $$driver_buffered_out_octets >= $high_mark ) | ||||||||||||||||||||||||||||||||||||||||||
| 217 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $$is_in_high_water_state = 1; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $k->call( $me, $$event_high, $unique_id ) if defined $$event_high; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | # All chunks written; fire off a "flushed" event. This | ||||||||||||||||||||||||||||||||||||||||||
| 224 | # occurs independently, so it's possible to get a low-water | ||||||||||||||||||||||||||||||||||||||||||
| 225 | # call and a flushed call at the same time (if the low mark | ||||||||||||||||||||||||||||||||||||||||||
| 226 | # is 1). | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 217 | ▶ | unless ($$driver_buffered_out_octets) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 217 | $k->select_pause_write($handle); | |||||||||||||||||||||||||||||||||||||||||
| 229 | 217 | ▶ | $$event_flushed && $k->call($me, $$event_flushed, $unique_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 136 | ); | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 136 | $poe_kernel->select_write($self->[HANDLE_OUTPUT], $self->[STATE_WRITE]); | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | # Pause the write select immediately, unless output is pending. | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 136 | ▶ | $poe_kernel->select_pause_write($self->[HANDLE_OUTPUT]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | unless ($self->[DRIVER_BUFFERED_OUT_OCTETS]); | ||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 242 | # Redefine the select-read handler. This uses stupid closure tricks | ||||||||||||||||||||||||||||||||||||||||||
| 243 | # to prevent keeping extra references to $self around. | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 138 | ▶ | sub _define_read_state { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_define_read_state: called CC=4 SCAR=15.5
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 138 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | # Register the select-read handler. | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 138 | ▶ | if (defined $self->[EVENT_INPUT]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | # If any of these change, then the read state is invalidated and | ||||||||||||||||||||||||||||||||||||||||||
| 253 | # needs to be redefined. | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 132 | my $driver = $self->[DRIVER_BOTH]; | |||||||||||||||||||||||||||||||||||||||||
| 256 | 132 | my $input_filter = \$self->[FILTER_INPUT]; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 132 | my $event_input = \$self->[EVENT_INPUT]; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 132 | my $event_error = \$self->[EVENT_ERROR]; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 132 | my $unique_id = $self->[UNIQUE_ID]; | |||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | # If the filter can get_one, then define the input state in terms | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # of get_one_start() and get_one(). | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 132 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$$input_filter->can("get_one") and $$input_filter->can("get_one_start")
MC/DC0%0/2
$$input_filter->can("get_one") and $$input_filter->can("get_one_start")
$$input_filter->can("get_one")
$$input_filter->can("get_one_start")
Truth table33%1/3
A and B
A= $$input_filter->can("get_one")B= $$input_filter->can("get_one_start")
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | $$input_filter->can('get_one') and | ||||||||||||||||||||||||||||||||||||||||||
| 266 | $$input_filter->can('get_one_start') | ||||||||||||||||||||||||||||||||||||||||||
| 267 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 268 | $poe_kernel->state( | ||||||||||||||||||||||||||||||||||||||||||
| 269 | $self->[STATE_READ] = ref($self) . "($unique_id) -> select read", | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 285 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | # Protects against coredump on older perls. | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 285 | 0 && CRIMSON_SCOPE_HACK('<'); | |||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | # The actual code starts here. | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 285 | my ($k, $me, $handle) = @_[KERNEL, SESSION, ARG0]; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 285 | ▶ | if (defined(my $raw_input = $driver->get($handle))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 221 | $$input_filter->get_one_start($raw_input); | |||||||||||||||||||||||||||||||||||||||||
| 279 | 221 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 280 | 434 | my $next_rec = $$input_filter->get_one(); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 434 | ▶ | last unless @$next_rec; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 213 | foreach my $cooked_input (@$next_rec) { | |||||||||||||||||||||||||||||||||||||||||
| 283 | 213 | $k->call($me, $$event_input, $cooked_input, $unique_id); | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 64 | ▶ | $$event_error and $k->call( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | $me, $$event_error, 'read', ($!+0), $!, $unique_id | ||||||||||||||||||||||||||||||||||||||||||
| 290 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 64 | $k->select_read($handle); | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 132 | ); | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | # Otherwise define the input state in terms of the older, less | ||||||||||||||||||||||||||||||||||||||||||
| 298 | # robust, yet faster get(). | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | $poe_kernel->state( | ||||||||||||||||||||||||||||||||||||||||||
| 302 | $self->[STATE_READ] = ref($self) . "($unique_id) -> select read", | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | # Protects against coredump on older perls. | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | 0 && CRIMSON_SCOPE_HACK('<'); | |||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | # The actual code starts here. | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my ($k, $me, $handle) = @_[KERNEL, SESSION, ARG0]; | |||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | if (defined(my $raw_input = $driver->get($handle))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | foreach my $cooked_input (@{$$input_filter->get($raw_input)}) { | |||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $k->call($me, $$event_input, $cooked_input, $unique_id); | |||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $$event_error and $k->call( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | $me, $$event_error, 'read', ($!+0), $!, $unique_id | ||||||||||||||||||||||||||||||||||||||||||
| 318 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $k->select_read($handle); | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | # register the state's select | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 132 | $poe_kernel->select_read($self->[HANDLE_INPUT], $self->[STATE_READ]); | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | # undefine the select, just in case | ||||||||||||||||||||||||||||||||||||||||||
| 328 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 6 | $poe_kernel->select_read($self->[HANDLE_INPUT]) | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 334 | # Redefine events. | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 4 | ▶ | sub event { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event: called CC=12 SCAR=25.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 338 | 4 | ▶ | push(@_, undef) if (scalar(@_) & 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 4 | my ($redefine_read, $redefine_write) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 14 | my ($name, $event) = splice(@_, 0, 2); | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 14 | ▶ | if ($name eq 'InputEvent') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | $self->[EVENT_INPUT] = $event; | |||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | $redefine_read = 1; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | elsif ($name eq 'ErrorEvent') { | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 4 | $self->[EVENT_ERROR] = $event; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 4 | $redefine_read = $redefine_write = 1; | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | elsif ($name eq 'FlushedEvent') { | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | $self->[EVENT_FLUSHED] = $event; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 4 | $redefine_write = 1; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | elsif ($name eq 'HighEvent') { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | ▶ | if (defined $self->[WATERMARK_WRITE_MARK_HIGH]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 2 | $self->[WATERMARK_WRITE_EVENT_HIGH] = $event; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | $redefine_write = 1; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | carp "Ignoring HighEvent (there is no high watermark set)"; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | elsif ($name eq 'LowEvent') { | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 2 | ▶ | if (defined $self->[WATERMARK_WRITE_MARK_LOW]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 2 | $self->[WATERMARK_WRITE_EVENT_LOW] = $event; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | $redefine_write = 1; | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | carp "Ignoring LowEvent (there is no high watermark set)"; | |||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | carp "ignoring unknown ReadWrite parameter '$name'"; | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 4 | ▶ | $self->_define_read_state() if $redefine_read; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 4 | ▶ | $self->_define_write_state() if $redefine_write; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 134 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 134 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | # Turn off the select. This is a problem if a wheel is being | ||||||||||||||||||||||||||||||||||||||||||
| 390 | # swapped, since it will turn off selects for the other wheel. | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 134 | ▶ | if ($self->[HANDLE_INPUT]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 134 | $poe_kernel->select_read($self->[HANDLE_INPUT]); | |||||||||||||||||||||||||||||||||||||||||
| 393 | 132 | $self->[HANDLE_INPUT] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 132 | ▶ | if ($self->[HANDLE_OUTPUT]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 132 | $poe_kernel->select_write($self->[HANDLE_OUTPUT]); | |||||||||||||||||||||||||||||||||||||||||
| 398 | 132 | $self->[HANDLE_OUTPUT] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 132 | ▶ | if ($self->[STATE_READ]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 130 | $poe_kernel->state($self->[STATE_READ]); | |||||||||||||||||||||||||||||||||||||||||
| 403 | 130 | $self->[STATE_READ] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 132 | ▶ | if ($self->[STATE_WRITE]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 132 | $poe_kernel->state($self->[STATE_WRITE]); | |||||||||||||||||||||||||||||||||||||||||
| 408 | 132 | $self->[STATE_WRITE] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 132 | &POE::Wheel::free_wheel_id($self->[UNIQUE_ID]); | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 415 | # TODO - We set the high/low watermark state here, but we don't fire | ||||||||||||||||||||||||||||||||||||||||||
| 416 | # events for it. My assumption is that the return value tells us | ||||||||||||||||||||||||||||||||||||||||||
| 417 | # all we want to know. | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 247 | ▶ | sub put { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put: called CC=8 SCAR=22.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 247 | my ($self, @chunks) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 247 | my $old_buffered_out_octets = $self->[DRIVER_BUFFERED_OUT_OCTETS]; | |||||||||||||||||||||||||||||||||||||||||
| 423 | 247 | my $new_buffered_out_octets = | |||||||||||||||||||||||||||||||||||||||||
| 424 | $self->[DRIVER_BUFFERED_OUT_OCTETS] = | ||||||||||||||||||||||||||||||||||||||||||
| 425 | $self->[DRIVER_BOTH]->put($self->[FILTER_OUTPUT]->put(\@chunks)); | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 247 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->[17] and $new_buffered_out_octets and not $old_buffered_out_octets
$self->[17] and $new_buffered_out_octets
MC/DC0%0/3
$self->[17] and $new_buffered_out_octets and not $old_buffered_out_octets
$self->[17]
$new_buffered_out_octets
not $old_buffered_out_octets
Truth table25%1/4
A and B and not(C)
A= $self->[17]B= $new_buffered_out_octetsC= not $old_buffered_out_octets
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | $self->[AUTOFLUSH] && | ||||||||||||||||||||||||||||||||||||||||||
| 429 | $new_buffered_out_octets and !$old_buffered_out_octets | ||||||||||||||||||||||||||||||||||||||||||
| 430 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $old_buffered_out_octets = $new_buffered_out_octets; | |||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $self->flush(); | |||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $new_buffered_out_octets = $self->[DRIVER_BUFFERED_OUT_OCTETS]; | |||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | # Resume write-ok if the output buffer gets data. This avoids | ||||||||||||||||||||||||||||||||||||||||||
| 437 | # redundant calls to select_resume_write(), which is probably a good | ||||||||||||||||||||||||||||||||||||||||||
| 438 | # thing. | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 247 | ▶ | if ($new_buffered_out_octets and !$old_buffered_out_octets) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$new_buffered_out_octets and not $old_buffered_out_octets
MC/DC50%1/2
$new_buffered_out_octets and not $old_buffered_out_octets
$new_buffered_out_octets
not $old_buffered_out_octets
Truth table66%2/3
A and not(B)
A= $new_buffered_out_octetsB= not $old_buffered_out_octets
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 219 | $poe_kernel->select_resume_write($self->[HANDLE_OUTPUT]); | |||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | # If the high watermark has been reached, return true. | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 247 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->[8] and $new_buffered_out_octets >= $self->[8]
MC/DC100%2/2
$self->[8] and $new_buffered_out_octets >= $self->[8]
$self->[8]
$new_buffered_out_octets >= $self->[8]
Truth table100%3/3
A and B
A= $self->[8]B= $new_buffered_out_octets >= $self->[8]
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | $self->[WATERMARK_WRITE_MARK_HIGH] and | ||||||||||||||||||||||||||||||||||||||||||
| 446 | $new_buffered_out_octets >= $self->[WATERMARK_WRITE_MARK_HIGH] | ||||||||||||||||||||||||||||||||||||||||||
| 447 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 8 | return $self->[WATERMARK_WRITE_STATE] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 239 | return $self->[WATERMARK_WRITE_STATE] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 455 | # Redefine filter. -PG / Now that there are two filters internally, | ||||||||||||||||||||||||||||||||||||||||||
| 456 | # one input and one output, make this set both of them at the same | ||||||||||||||||||||||||||||||||||||||||||
| 457 | # time. -RCC | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 41 | ▶ | sub _transfer_input_buffer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_transfer_input_buffer: called CC=9 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 41 | my ($self, $buf) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 41 | my $old_input_filter = $self->[FILTER_INPUT]; | |||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | # If the new filter implements "get_one", use that. | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 41 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$old_input_filter->can("get_one") and $old_input_filter->can("get_one_start")
MC/DC0%0/2
$old_input_filter->can("get_one") and $old_input_filter->can("get_one_start")
$old_input_filter->can("get_one")
$old_input_filter->can("get_one_start")
Truth table33%1/3
A and B
A= $old_input_filter->can("get_one")B= $old_input_filter->can("get_one_start")
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | $old_input_filter->can('get_one') and | ||||||||||||||||||||||||||||||||||||||||||
| 467 | $old_input_filter->can('get_one_start') | ||||||||||||||||||||||||||||||||||||||||||
| 468 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 469 | 41 | ▶ | if (defined $buf) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | 9 | $self->[FILTER_INPUT]->get_one_start($buf); | |||||||||||||||||||||||||||||||||||||||||
| 471 | 9 | ▶ | while ($self->[FILTER_INPUT] == $old_input_filter) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 19 | my $next_rec = $self->[FILTER_INPUT]->get_one(); | |||||||||||||||||||||||||||||||||||||||||
| 473 | 19 | ▶ | last unless @$next_rec; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 18 | foreach my $cooked_input (@$next_rec) { | |||||||||||||||||||||||||||||||||||||||||
| 475 | 18 | $poe_kernel->call( | |||||||||||||||||||||||||||||||||||||||||
| 476 | $poe_kernel->get_active_session(), | ||||||||||||||||||||||||||||||||||||||||||
| 477 | $self->[EVENT_INPUT], | ||||||||||||||||||||||||||||||||||||||||||
| 478 | $cooked_input, $self->[UNIQUE_ID] | ||||||||||||||||||||||||||||||||||||||||||
| 479 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | # Otherwise use the old behavior. | ||||||||||||||||||||||||||||||||||||||||||
| 486 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | if (defined $buf) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | foreach my $cooked_input (@{$self->[FILTER_INPUT]->get($buf)}) { | |||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $poe_kernel->call( | |||||||||||||||||||||||||||||||||||||||||
| 490 | $poe_kernel->get_active_session(), | ||||||||||||||||||||||||||||||||||||||||||
| 491 | $self->[EVENT_INPUT], | ||||||||||||||||||||||||||||||||||||||||||
| 492 | $cooked_input, $self->[UNIQUE_ID] | ||||||||||||||||||||||||||||||||||||||||||
| 493 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | # Set input and output filters. | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 32 | ▶ | sub set_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_filter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 32 | my ($self, $new_filter) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 32 | my $buf = $self->[FILTER_INPUT]->get_pending(); | |||||||||||||||||||||||||||||||||||||||||
| 504 | 32 | $self->[FILTER_INPUT] = $self->[FILTER_OUTPUT] = $new_filter; | |||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 32 | $self->_transfer_input_buffer($buf); | |||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | # Redefine input and/or output filters separately. | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 9 | ▶ | sub set_input_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_input_filter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 9 | my ($self, $new_filter) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 512 | 9 | my $buf = $self->[FILTER_INPUT]->get_pending(); | |||||||||||||||||||||||||||||||||||||||||
| 513 | 9 | $self->[FILTER_INPUT] = $new_filter; | |||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | 9 | $self->_transfer_input_buffer($buf); | |||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | # No closures need to be redefined or anything. All the previously | ||||||||||||||||||||||||||||||||||||||||||
| 519 | # put stuff has been serialized already. | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 9 | ▶ | sub set_output_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_output_filter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | 9 | my ($self, $new_filter) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 522 | 9 | $self->[FILTER_OUTPUT] = $new_filter; | |||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | # Get the current input filter; used for accessing the filter's custom | ||||||||||||||||||||||||||||||||||||||||||
| 526 | # methods, as in: $wheel->get_input_filter()->filter_method(); | ||||||||||||||||||||||||||||||||||||||||||
| 527 | 2 | ▶ | sub get_input_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_input_filter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 2 | return $self->[FILTER_INPUT]; | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | # Get the current input filter; used for accessing the filter's custom | ||||||||||||||||||||||||||||||||||||||||||
| 533 | # methods, as in: $wheel->get_input_filter()->filter_method(); | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 2 | ▶ | sub get_output_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_output_filter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 536 | 2 | return $self->[FILTER_OUTPUT]; | |||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | # Set the high water mark. | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | sub set_high_mark { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_high_mark: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | my ($self, $new_high_mark) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | unless (defined $self->[WATERMARK_WRITE_MARK_HIGH]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | carp "Ignoring high mark (must be initialized in constructor first)"; | |||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | unless (defined $new_high_mark) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | carp "New high mark is undefined. Ignored"; | |||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | unless ($new_high_mark > $self->[WATERMARK_WRITE_MARK_LOW]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | carp "New high mark would not be greater than low mark. Ignored"; | |||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $self->[WATERMARK_WRITE_MARK_HIGH] = $new_high_mark; | |||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | $self->_define_write_state(); | |||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | sub set_low_mark { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_low_mark: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my ($self, $new_low_mark) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | unless (defined $self->[WATERMARK_WRITE_MARK_LOW]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | carp "Ignoring low mark (must be initialized in constructor first)"; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | unless (defined $new_low_mark) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | carp "New low mark is undefined. Ignored"; | |||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | unless ($new_low_mark > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | carp "New low mark would be less than one. Ignored"; | |||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | unless ($new_low_mark < $self->[WATERMARK_WRITE_MARK_HIGH]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | carp "New low mark would not be less than high high mark. Ignored"; | |||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $self->[WATERMARK_WRITE_MARK_LOW] = $new_low_mark; | |||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $self->_define_write_state(); | |||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | # Return driver statistics. | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 56 | ▶ | sub get_driver_out_octets { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_driver_out_octets: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 56 | $_[0]->[DRIVER_BUFFERED_OUT_OCTETS]; | |||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 4 | ▶ | sub get_driver_out_messages { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_driver_out_messages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 4 | $_[0]->[DRIVER_BOTH]->get_out_messages_buffered(); | |||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | # Get the wheel's ID. | ||||||||||||||||||||||||||||||||||||||||||
| 600 | 12 | ▶ | sub ID { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ID: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | 12 | return $_[0]->[UNIQUE_ID]; | |||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||
| 604 | # Pause the wheel's input watcher. | ||||||||||||||||||||||||||||||||||||||||||
| 605 | 2 | ▶ | sub pause_input { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pause_input: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 607 | 2 | ▶ | return unless defined $self->[HANDLE_INPUT]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 608 | 2 | $poe_kernel->select_pause_read( $self->[HANDLE_INPUT] ); | |||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | # Resume the wheel's input watcher. | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 2 | ▶ | sub resume_input { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume_input: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 614 | 2 | ▶ | return unless defined $self->[HANDLE_INPUT]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | 2 | $poe_kernel->select_resume_read( $self->[HANDLE_INPUT] ); | |||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | # Return the wheel's input handle | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | sub get_input_handle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_input_handle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | return $self->[HANDLE_INPUT]; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | # Return the wheel's output handle | ||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | sub get_output_handle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_output_handle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | return $self->[HANDLE_OUTPUT]; | |||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | # Shutdown the socket for reading. | ||||||||||||||||||||||||||||||||||||||||||
| 631 | 2 | ▶ | sub shutdown_input { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown_input: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 633 | 2 | ▶ | return unless defined $self->[HANDLE_INPUT]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | 2 | eval { local $^W = 0; shutdown($self->[HANDLE_INPUT], 0) }; | |||||||||||||||||||||||||||||||||||||||||
| 635 | 2 | $poe_kernel->select_read($self->[HANDLE_INPUT], undef); | |||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | # Shutdown the socket for writing. | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 2 | ▶ | sub shutdown_output { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown_output: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 641 | 2 | ▶ | return unless defined $self->[HANDLE_OUTPUT]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | eval { local $^W=0; shutdown($self->[HANDLE_OUTPUT], 1) }; | |||||||||||||||||||||||||||||||||||||||||
| 643 | 2 | $poe_kernel->select_write($self->[HANDLE_OUTPUT], undef); | |||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | # Flush the output handle | ||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | sub flush { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | return unless defined $self->[HANDLE_OUTPUT]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | $poe_kernel->call($poe_kernel->get_active_session(), | |||||||||||||||||||||||||||||||||||||||||
| 651 | $self->[STATE_WRITE], $self->[HANDLE_OUTPUT]); | ||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | 27 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | __END__ | ||||||||||||||||||||||||||||||||||||||||||