GRPC C++  1.62.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 
18 
19 #include <algorithm>
20 #include <memory>
21 #include <type_traits>
22 #include <vector>
23 
25 #include <grpc/slice.h>
26 
27 namespace grpc_event_engine {
28 namespace experimental {
29 
30 namespace internal {
31 
36  : public std::enable_shared_from_this<MemoryAllocatorImpl> {
37  public:
39  virtual ~MemoryAllocatorImpl() {}
40 
43 
51  virtual size_t Reserve(MemoryRequest request) = 0;
52 
57  virtual grpc_slice MakeSlice(MemoryRequest request) = 0;
58 
62  virtual void Release(size_t n) = 0;
63 
66  virtual void Shutdown() = 0;
67 };
68 
69 } // namespace internal
70 
71 } // namespace experimental
72 } // namespace grpc_event_engine
73 
74 #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:35
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:38
slice.h
grpc_event_engine
Definition: endpoint_config.h:24
grpc_event_engine::experimental::internal::MemoryAllocatorImpl::~MemoryAllocatorImpl
virtual ~MemoryAllocatorImpl()
Definition: memory_allocator_impl.h:39
port_platform.h