YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/rpc/call_data.h
Line
Count
Source
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_RPC_CALL_DATA_H
15
#define YB_RPC_CALL_DATA_H
16
17
#include "yb/util/ref_cnt_buffer.h"
18
#include "yb/util/strongly_typed_bool.h"
19
20
namespace yb {
21
namespace rpc {
22
23
struct CallData {
24
 public:
25
253M
  CallData() : buffer_(EmptyBuffer()) {}
26
27
152M
  explicit CallData(size_t size) : buffer_(size) {}
28
  class ShouldRejectTag {};
29
30
327
  CallData(size_t size, ShouldRejectTag) {}
31
32
  CallData(const CallData&) = delete;
33
  void operator=(const CallData&) = delete;
34
35
  CallData(CallData&& rhs) = default;
36
225M
  CallData& operator=(CallData&& rhs) = default;
37
38
153M
  bool empty() const {
39
153M
    return buffer_.empty();
40
153M
  }
41
42
305M
  char* data() const {
43
305M
    return buffer_.data();
44
305M
  }
45
46
158M
  bool should_reject() const { return !buffer_; }
47
48
5.03M
  void Reset() {
49
5.03M
    buffer_.Reset();
50
5.03M
  }
51
52
535M
  size_t size() const {
53
535M
    return buffer_.size();
54
535M
  }
55
56
7.21M
  const RefCntBuffer& buffer() const {
57
7.21M
    return buffer_;
58
7.21M
  }
59
60
72.6M
  size_t DynamicMemoryUsage() const { return buffer_.DynamicMemoryUsage(); }
61
62
 private:
63
253M
  static RefCntBuffer EmptyBuffer() {
64
253M
    static RefCntBuffer result(0);
65
253M
    return result;
66
253M
  }
67
68
  RefCntBuffer buffer_;
69
};
70
71
} // namespace rpc
72
} // namespace yb
73
74
#endif // YB_RPC_CALL_DATA_H