class MemoryAllocator

Defined at line 34 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

Tracks memory allocated by one system.

Is effectively a thin wrapper/smart pointer for a MemoryAllocatorImpl,

providing a convenient and stable API.

Public Methods

void MemoryAllocator (std::shared_ptr<internal::MemoryAllocatorImpl> allocator)

Construct a MemoryAllocator given an internal::MemoryAllocatorImpl

implementation. The constructed MemoryAllocator will call

MemoryAllocatorImpl::Shutdown() upon destruction.

Defined at line 39 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

void MemoryAllocator ()

Construct an invalid MemoryAllocator.

Defined at line 43 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

void ~MemoryAllocator ()

Defined at line 44 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

void MemoryAllocator (const MemoryAllocator & )

Defined at line 48 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

MemoryAllocator & operator= (const MemoryAllocator & )

Defined at line 49 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

void MemoryAllocator (MemoryAllocator && )

Defined at line 51 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

MemoryAllocator & operator= (MemoryAllocator && )

Defined at line 52 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

void Reset ()

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.

Defined at line 57 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

size_t Reserve (MemoryRequest request)

Reserve bytes from the quota.

If we enter overcommit, reclamation will begin concurrently.

Returns the number of bytes reserved.

Defined at line 65 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

void Release (size_t n)

Release some bytes that were previously reserved.

Defined at line 68 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

Reservation MakeReservation (MemoryRequest request)

Reserve bytes from the quota and automatically release them when

Reservation is destroyed.

Defined at line 99 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

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

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.

Defined at line 108 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

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

Construct a unique_ptr immediately.

Defined at line 128 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

grpc_slice 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.

Defined at line 136 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

Protected Methods

internal::MemoryAllocatorImpl * get_internal_impl_ptr ()

Return a pointer to the underlying implementation.

Note that the interface of said implementation is unstable and likely to

change at any time.

Defined at line 175 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

const internal::MemoryAllocatorImpl * get_internal_impl_ptr ()

Defined at line 179 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/memory_allocator.h

Records