Classes | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
grpc_event_engine::experimental::MemoryAllocator Class Reference

#include <memory_allocator.h>

Inheritance diagram for grpc_event_engine::experimental::MemoryAllocator:
Inheritance graph
[legend]

Classes

class  Container
 A C++ allocator for containers of T. More...
 
class  Reservation
 An automatic releasing reservation of memory. More...
 

Public Member Functions

Reservation MakeReservation (MemoryRequest request)
 
grpc_slice MakeSlice (MemoryRequest request)
 
template<typename T , typename... Args>
std::unique_ptr< TMakeUnique (Args &&... args)
 Construct a unique_ptr immediately. More...
 
 MemoryAllocator ()
 
 MemoryAllocator (const MemoryAllocator &)=delete
 
 MemoryAllocator (MemoryAllocator &&)=default
 
 MemoryAllocator (std::shared_ptr< internal::MemoryAllocatorImpl > allocator)
 
template<typename T , typename... Args>
std::enable_if< std::has_virtual_destructor< T >::value, T * >::type New (Args &&... args)
 
MemoryAllocatoroperator= (const MemoryAllocator &)=delete
 
MemoryAllocatoroperator= (MemoryAllocator &&)=default
 
void Release (size_t n)
 Release some bytes that were previously reserved. More...
 
size_t Reserve (MemoryRequest request)
 
void Reset ()
 
 ~MemoryAllocator ()
 

Protected Member Functions

internal::MemoryAllocatorImplget_internal_impl_ptr ()
 
const internal::MemoryAllocatorImplget_internal_impl_ptr () const
 

Private Attributes

std::shared_ptr< internal::MemoryAllocatorImplallocator_
 

Detailed Description

Definition at line 35 of file memory_allocator.h.

Constructor & Destructor Documentation

◆ MemoryAllocator() [1/4]

grpc_event_engine::experimental::MemoryAllocator::MemoryAllocator ( std::shared_ptr< internal::MemoryAllocatorImpl allocator)
inlineexplicit

Construct a MemoryAllocator given an internal::MemoryAllocatorImpl implementation. The constructed MemoryAllocator will call MemoryAllocatorImpl::Shutdown() upon destruction.

Definition at line 40 of file memory_allocator.h.

◆ MemoryAllocator() [2/4]

grpc_event_engine::experimental::MemoryAllocator::MemoryAllocator ( )
inline

Definition at line 44 of file memory_allocator.h.

◆ ~MemoryAllocator()

grpc_event_engine::experimental::MemoryAllocator::~MemoryAllocator ( )
inline

Definition at line 45 of file memory_allocator.h.

◆ MemoryAllocator() [3/4]

grpc_event_engine::experimental::MemoryAllocator::MemoryAllocator ( const MemoryAllocator )
delete

◆ MemoryAllocator() [4/4]

grpc_event_engine::experimental::MemoryAllocator::MemoryAllocator ( MemoryAllocator &&  )
default

Member Function Documentation

◆ get_internal_impl_ptr() [1/2]

internal::MemoryAllocatorImpl* grpc_event_engine::experimental::MemoryAllocator::get_internal_impl_ptr ( )
inlineprotected

Return a pointer to the underlying implementation. Note that the interface of said implementation is unstable and likely to change at any time.

Definition at line 174 of file memory_allocator.h.

◆ get_internal_impl_ptr() [2/2]

const internal::MemoryAllocatorImpl* grpc_event_engine::experimental::MemoryAllocator::get_internal_impl_ptr ( ) const
inlineprotected

Definition at line 178 of file memory_allocator.h.

◆ MakeReservation()

Reservation grpc_event_engine::experimental::MemoryAllocator::MakeReservation ( MemoryRequest  request)
inline

Reserve bytes from the quota and automatically release them when Reservation is destroyed.

Definition at line 100 of file memory_allocator.h.

◆ MakeSlice()

grpc_slice grpc_event_engine::experimental::MemoryAllocator::MakeSlice ( MemoryRequest  request)

Allocate a slice, using MemoryRequest to size the number of returned bytes. For a variable length request, check the returned slice length to verify how much memory was allocated. Takes care of reserving memory for any relevant control structures also.

Definition at line 61 of file memory_allocator.cc.

◆ MakeUnique()

template<typename T , typename... Args>
std::unique_ptr<T> grpc_event_engine::experimental::MemoryAllocator::MakeUnique ( Args &&...  args)
inline

Construct a unique_ptr immediately.

Definition at line 129 of file memory_allocator.h.

◆ New()

template<typename T , typename... Args>
std::enable_if<std::has_virtual_destructor<T>::value, T*>::type grpc_event_engine::experimental::MemoryAllocator::New ( Args &&...  args)
inline

Allocate a new object of type T, with constructor arguments. The returned type is wrapped, and upon destruction the reserved memory will be released to the allocator automatically. As such, T must have a virtual destructor so we can insert the necessary hook.

Definition at line 109 of file memory_allocator.h.

◆ operator=() [1/2]

MemoryAllocator& grpc_event_engine::experimental::MemoryAllocator::operator= ( const MemoryAllocator )
delete

◆ operator=() [2/2]

MemoryAllocator& grpc_event_engine::experimental::MemoryAllocator::operator= ( MemoryAllocator &&  )
default

◆ Release()

void grpc_event_engine::experimental::MemoryAllocator::Release ( size_t  n)
inline

Release some bytes that were previously reserved.

Definition at line 69 of file memory_allocator.h.

◆ Reserve()

size_t grpc_event_engine::experimental::MemoryAllocator::Reserve ( MemoryRequest  request)
inline

Reserve bytes from the quota. If we enter overcommit, reclamation will begin concurrently. Returns the number of bytes reserved.

Definition at line 66 of file memory_allocator.h.

◆ Reset()

void grpc_event_engine::experimental::MemoryAllocator::Reset ( )
inline

Drop the underlying allocator and make this an empty object. The object will not be usable after this call unless it's a valid allocator is moved into it.

Definition at line 58 of file memory_allocator.h.

Member Data Documentation

◆ allocator_

std::shared_ptr<internal::MemoryAllocatorImpl> grpc_event_engine::experimental::MemoryAllocator::allocator_
private

Definition at line 183 of file memory_allocator.h.


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


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:40