GRPC C++  1.66.0
memory_allocator_impl.h
Go to the documentation of this file.
1 // Copyright 2021 The gRPC Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #ifndef GRPC_EVENT_ENGINE_INTERNAL_MEMORY_ALLOCATOR_IMPL_H
15 #define GRPC_EVENT_ENGINE_INTERNAL_MEMORY_ALLOCATOR_IMPL_H
16 
17 #include <algorithm>
18 #include <memory>
19 #include <type_traits>
20 #include <vector>
21 
23 #include <grpc/slice.h>
25 
26 namespace grpc_event_engine {
27 namespace experimental {
28 
29 namespace internal {
30 
35  : public std::enable_shared_from_this<MemoryAllocatorImpl> {
36  public:
38  virtual ~MemoryAllocatorImpl() {}
39 
42 
50  virtual size_t Reserve(MemoryRequest request) = 0;
51 
56  virtual grpc_slice MakeSlice(MemoryRequest request) = 0;
57 
61  virtual void Release(size_t n) = 0;
62 
65  virtual void Shutdown() = 0;
66 };
67 
68 } // namespace internal
69 
70 } // namespace experimental
71 } // namespace grpc_event_engine
72 
73 #endif // GRPC_EVENT_ENGINE_INTERNAL_MEMORY_ALLOCATOR_IMPL_H
grpc_event_engine::experimental::internal::MemoryAllocatorImpl::Reserve
virtual size_t Reserve(MemoryRequest request)=0
Reserve bytes from the quota.
grpc_event_engine::experimental::internal::MemoryAllocatorImpl::Shutdown
virtual void Shutdown()=0
Shutdown this allocator.
grpc_event_engine::experimental::internal::MemoryAllocatorImpl::MakeSlice
virtual grpc_slice MakeSlice(MemoryRequest request)=0
Allocate a slice, using MemoryRequest to size the number of returned bytes.
grpc_event_engine::experimental::internal::MemoryAllocatorImpl
Underlying memory allocation interface.
Definition: memory_allocator_impl.h:34
grpc_event_engine::experimental::MemoryRequest
Reservation request - how much memory do we want to allocate?
Definition: memory_request.h:27
grpc_event_engine::experimental::internal::MemoryAllocatorImpl::Release
virtual void Release(size_t n)=0
Release some bytes that were previously reserved.
grpc_slice
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice_type.h:63
memory_request.h
grpc_event_engine::experimental::internal::MemoryAllocatorImpl::operator=
MemoryAllocatorImpl & operator=(const MemoryAllocatorImpl &)=delete
grpc_event_engine::experimental::internal::MemoryAllocatorImpl::MemoryAllocatorImpl
MemoryAllocatorImpl()
Definition: memory_allocator_impl.h:37
slice.h
grpc_event_engine
Definition: endpoint_config.h:24
grpc_event_engine::experimental::internal::MemoryAllocatorImpl::~MemoryAllocatorImpl
virtual ~MemoryAllocatorImpl()
Definition: memory_allocator_impl.h:38
port_platform.h