ONE - On-device Neural Engine
Loading...
Searching...
No Matches
flatbuffers::grpc::SliceAllocator Class Reference

#include <grpc.h>

Collaboration diagram for flatbuffers::grpc::SliceAllocator:

Public Member Functions

 SliceAllocator ()
 
 SliceAllocator (const SliceAllocator &other)=delete
 
SliceAllocatoroperator= (const SliceAllocator &other)=delete
 
 SliceAllocator (SliceAllocator &&other)
 
SliceAllocatoroperator= (SliceAllocator &&other)
 
void swap (SliceAllocator &other)
 
virtual ~SliceAllocator ()
 
virtual uint8_t * allocate (size_t size) override
 
virtual void deallocate (uint8_t *p, size_t size) override
 
virtual uint8_t * reallocate_downward (uint8_t *old_p, size_t old_size, size_t new_size, size_t in_use_back, size_t in_use_front) override
 
- Public Member Functions inherited from flatbuffers::Allocator
virtual ~Allocator ()
 

Friends

class MessageBuilder
 

Additional Inherited Members

- Protected Member Functions inherited from flatbuffers::Allocator
void memcpy_downward (uint8_t *old_p, size_t old_size, uint8_t *new_p, size_t new_size, size_t in_use_back, size_t in_use_front)
 

Detailed Description

Definition at line 87 of file grpc.h.

Constructor & Destructor Documentation

◆ SliceAllocator() [1/3]

flatbuffers::grpc::SliceAllocator::SliceAllocator ( )
inline

Definition at line 90 of file grpc.h.

90: slice_(grpc_empty_slice()) {}

◆ SliceAllocator() [2/3]

flatbuffers::grpc::SliceAllocator::SliceAllocator ( const SliceAllocator other)
delete

◆ SliceAllocator() [3/3]

flatbuffers::grpc::SliceAllocator::SliceAllocator ( SliceAllocator &&  other)
inline

Definition at line 95 of file grpc.h.

95 : slice_(grpc_empty_slice())
96 {
97 // default-construct and swap idiom
98 swap(other);
99 }
void swap(SliceAllocator &other)
Definition grpc.h:109

References swap().

◆ ~SliceAllocator()

virtual flatbuffers::grpc::SliceAllocator::~SliceAllocator ( )
inlinevirtual

Definition at line 115 of file grpc.h.

115{ grpc_slice_unref(slice_); }

Member Function Documentation

◆ allocate()

virtual uint8_t * flatbuffers::grpc::SliceAllocator::allocate ( size_t  size)
inlineoverridevirtual

Implements flatbuffers::Allocator.

Definition at line 117 of file grpc.h.

118 {
119 FLATBUFFERS_ASSERT(GRPC_SLICE_IS_EMPTY(slice_));
120 slice_ = grpc_slice_malloc(size);
121 return GRPC_SLICE_START_PTR(slice_);
122 }
#define FLATBUFFERS_ASSERT
Definition base.h:37
int32_t size[5]
Definition Slice.cpp:35

References FLATBUFFERS_ASSERT, and size.

◆ deallocate()

virtual void flatbuffers::grpc::SliceAllocator::deallocate ( uint8_t *  p,
size_t  size 
)
inlineoverridevirtual

Implements flatbuffers::Allocator.

Definition at line 124 of file grpc.h.

125 {
126 FLATBUFFERS_ASSERT(p == GRPC_SLICE_START_PTR(slice_));
127 FLATBUFFERS_ASSERT(size == GRPC_SLICE_LENGTH(slice_));
128 grpc_slice_unref(slice_);
129 slice_ = grpc_empty_slice();
130 }

References FLATBUFFERS_ASSERT, and size.

◆ operator=() [1/2]

SliceAllocator & flatbuffers::grpc::SliceAllocator::operator= ( const SliceAllocator other)
delete

◆ operator=() [2/2]

SliceAllocator & flatbuffers::grpc::SliceAllocator::operator= ( SliceAllocator &&  other)
inline

Definition at line 101 of file grpc.h.

102 {
103 // move-construct and swap idiom
104 SliceAllocator temp(std::move(other));
105 swap(temp);
106 return *this;
107 }

References swap().

◆ reallocate_downward()

virtual uint8_t * flatbuffers::grpc::SliceAllocator::reallocate_downward ( uint8_t *  old_p,
size_t  old_size,
size_t  new_size,
size_t  in_use_back,
size_t  in_use_front 
)
inlineoverridevirtual

Reimplemented from flatbuffers::Allocator.

Definition at line 132 of file grpc.h.

134 {
135 FLATBUFFERS_ASSERT(old_p == GRPC_SLICE_START_PTR(slice_));
136 FLATBUFFERS_ASSERT(old_size == GRPC_SLICE_LENGTH(slice_));
137 FLATBUFFERS_ASSERT(new_size > old_size);
138 grpc_slice old_slice = slice_;
139 grpc_slice new_slice = grpc_slice_malloc(new_size);
140 uint8_t *new_p = GRPC_SLICE_START_PTR(new_slice);
141 memcpy_downward(old_p, old_size, new_p, new_size, in_use_back, in_use_front);
142 slice_ = new_slice;
143 grpc_slice_unref(old_slice);
144 return new_p;
145 }
void memcpy_downward(uint8_t *old_p, size_t old_size, uint8_t *new_p, size_t new_size, size_t in_use_back, size_t in_use_front)

References FLATBUFFERS_ASSERT, and flatbuffers::Allocator::memcpy_downward().

◆ swap()

void flatbuffers::grpc::SliceAllocator::swap ( SliceAllocator other)
inline

Definition at line 109 of file grpc.h.

110 {
111 using std::swap;
112 swap(slice_, other.slice_);
113 }

References swap().

Referenced by operator=(), SliceAllocator(), and swap().

Friends And Related Symbol Documentation

◆ MessageBuilder

friend class MessageBuilder
friend

Definition at line 157 of file grpc.h.


The documentation for this class was generated from the following file: