blib/lib/Thrift/BufferedTransport.pm

filter: Statementstmt 43.9% 29 / 66 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 47.3% 9 / 19 Podpod 0.0% 0 / 8 totaltotal 36.8% 38 / 103 CC 5 SCAR 12.8
CC
5
Cov
39%
new
12.0
write
6.0
flush
6.0
CRAP 3.6
« gen-perl2/Aggr.pm ↑ Summary gen-perl/BenchmarkService.pm »
1 #
2 # Licensed to the Apache Software Foundation (ASF) under one
3 # or more contributor license agreements. See the NOTICE file
4 # distributed with this work for additional information
5 # regarding copyright ownership. The ASF licenses this file
6 # to you under the Apache License, Version 2.0 (the
7 # "License"); you may not use this file except in compliance
8 # with the License. You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing,
13 # software distributed under the License is distributed on an
14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 # KIND, either express or implied. See the License for the
16 # specific language governing permissions and limitations
17 # under the License.
18 #
19  
20 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use Thrift;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Thrift::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Thrift::Transport;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 package Thrift::BufferedTransport;
29 1 ▶use base('Thrift::Transport');
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 sub new
33 0 ▶{
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
34 0 my $classname = shift;
35 0 my $transport = shift;
36 0 ▶ my $rBufSize = shift || 512;
Condition0%0/2
shift() || 512
l!l
00
MC/DC0%0/1
shift() || 512
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
37 0 ▶ my $wBufSize = shift || 512;
Condition0%0/2
shift() || 512
l!l
00
MC/DC0%0/1
shift() || 512
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
38  
39 0 my $self = {
40 transport => $transport,
41 rBufSize => $rBufSize,
42 wBufSize => $wBufSize,
43 wBuf => '',
44 rBuf => '',
45 };
46  
47 0 return bless($self,$classname);
48 }
49  
50 sub isOpen
51 0 ▶{
Subroutine isOpen: not called CC=1 SCAR=6.9
Pod undocumented
52 0 my $self = shift;
53  
54 0 return $self->{transport}->isOpen();
55 }
56  
57 sub open
58 0 ▶{
Subroutine open: not called CC=1 SCAR=6.9
Pod undocumented
59 0 my $self = shift;
60 0 $self->{transport}->open();
61 }
62  
63 sub close()
64 0 ▶{
Subroutine close: not called CC=1 SCAR=6.9
Pod undocumented
65 0 my $self = shift;
66 0 $self->{transport}->close();
67 }
68  
69 sub readAll
70 0 ▶{
Subroutine readAll: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my $self = shift;
72 0 my $len = shift;
73  
74 0 return $self->{transport}->readAll($len);
75 }
76  
77 sub read
78 0 ▶{
Subroutine read: not called CC=1 SCAR=6.9
Pod undocumented
79 0 my $self = shift;
80 0 my $len = shift;
81 0 my $ret;
82  
83 # Methinks Perl is already buffering these for us
84 0 return $self->{transport}->read($len);
85 }
86  
87 sub write
88 0 ▶{
Subroutine write: not called CC=2 SCAR=17.9
Pod undocumented
89 0 my $self = shift;
90 0 my $buf = shift;
91  
92 0 $self->{wBuf} .= $buf;
93 0 ▶ if (length($self->{wBuf}) >= $self->{wBufSize}) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"wBuf"} >= $self->{"wBufSize"}) 0 0 0
94 0 $self->{transport}->write($self->{wBuf});
95 0 $self->{wBuf} = '';
96 }
97 }
98  
99 sub flush
100 0 ▶{
Subroutine flush: not called CC=2 SCAR=17.9
Pod undocumented
101 0 my $self = shift;
102  
103 0 ▶ if (length($self->{wBuf}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"wBuf"} > 0) 0 0 0
104 0 $self->{transport}->write($self->{wBuf});
105 0 $self->{wBuf} = '';
106 }
107 0 $self->{transport}->flush();
108 }
109  
110  
111 #
112 # BufferedTransport factory creates buffered transport objects from transports
113 #
114 package Thrift::BufferedTransportFactory;
115 1 ▶use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
Subroutine BEGIN: called CC=1 SCAR=0.0
116  
117 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
118 0 my $classname = shift;
119 0 my $self = {};
120  
121 0 return bless($self,$classname);
122 }
123  
124 #
125 # Build a buffered transport from the base transport
126 #
127 # @return Thrift::BufferedTransport transport
128 #
129 sub getTransport
130 0 ▶{
Subroutine getTransport: not called CC=1 SCAR=6.9
131 0 my $self = shift;
132 0 my $trans = shift;
133  
134 0 my $buffered = Thrift::BufferedTransport->new($trans);
135 0 return $buffered;
136 }
137  
138  
139 1 1;
« gen-perl2/Aggr.pm ↑ Summary gen-perl/BenchmarkService.pm »