| 1 | package POE::Filter::ThruPut; | ||||||||||
| 2 | 2 | $POE::Filter::ThruPut::VERSION = '1.00'; | |||||||||
| 3 | #ABSTRACT: a POE filter that passes data through unchanged whilst counting bytes sent and received | ||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use POE::Filter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | require bytes; | |||||||||
| 8 | |||||||||||
| 9 | 2 | our @ISA = qw(POE::Filter); | |||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 12 | 1 | my $type = shift; | |||||||||
| 13 | 1 | my $self = bless { buffer => '', in => 0, out => 0 }, $type; | |||||||||
| 14 | 1 | $self; | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | sub clone { | ||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 18 | 1 | my $self = shift; | |||||||||
| 19 | 1 | my $clone = bless { buffer => '', in => 0, out => 0 }, ref $self; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 2 | ▶ | sub get_one_start { | ||||||||
|
Subroutine
get_one_start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | 2 | my ($self, $stream) = @_; | |||||||||
| 24 | 2 | my $dat = join '', @$stream; | |||||||||
| 25 | 2 | $self->{in} += bytes::length $dat; | |||||||||
| 26 | 2 | $self->{buffer} .= $dat; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 4 | ▶ | sub get_one { | ||||||||
|
Subroutine
get_one: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 4 | my $self = shift; | |||||||||
| 31 | 4 | ▶ | return [ ] unless CORE::length($self->{buffer}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 2 | my $chunk = $self->{buffer}; | |||||||||
| 33 | 2 | $self->{buffer} = ''; | |||||||||
| 34 | 2 | return [ $chunk ]; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 2 | ▶ | sub put { | ||||||||
|
Subroutine
put: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 38 | 2 | my ($self, $chunks) = @_; | |||||||||
| 39 | 2 | $self->{out} += bytes::length(join '', @$chunks); | |||||||||
| 40 | 2 | [ @$chunks ]; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub get_pending { | ||||||||
|
Subroutine
get_pending: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 44 | 0 | my $self = shift; | |||||||||
| 45 | 0 | ▶ | return undef if !CORE::length($self->{buffer}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | $self->{in} += bytes::length($self->{buffer}); | |||||||||
| 47 | 0 | return [ $self->{buffer} ]; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 2 | ▶ | sub send { | ||||||||
|
Subroutine
send: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 51 | 2 | my $self = shift; | |||||||||
| 52 | 2 | return $self->{out}; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 2 | ▶ | sub recv { | ||||||||
|
Subroutine
recv: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 56 | 2 | my $self = shift; | |||||||||
| 57 | 2 | return $self->{in}; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub stats { | ||||||||
|
Subroutine
stats: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | 0 | my $self = shift; | |||||||||
| 62 | 0 | return [ $self->{out}, $self->{in} ]; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 2 | 'Are you receiving?'; | |||||||||
| 66 | |||||||||||
| 67 | __END__ | ||||||||||