Public Member Functions | Private Member Functions | Private Attributes | List of all members
grpc_core::GrpcMemoryAllocatorImpl Class Referencefinal

#include <memory_quota.h>

Inheritance diagram for grpc_core::GrpcMemoryAllocatorImpl:
Inheritance graph
[legend]

Public Member Functions

 GrpcMemoryAllocatorImpl (std::shared_ptr< BasicMemoryQuota > memory_quota, std::string name)
 
double InstantaneousPressure () const
 
absl::string_view name () const
 
template<typename F >
void PostReclaimer (ReclamationPass pass, F fn)
 
void Release (size_t n) override
 
size_t Reserve (MemoryRequest request) override
 
void Shutdown () override
 
 ~GrpcMemoryAllocatorImpl () override
 
- Public Member Functions inherited from grpc_event_engine::experimental::internal::MemoryAllocatorImpl
 MemoryAllocatorImpl ()
 
 MemoryAllocatorImpl (const MemoryAllocatorImpl &)=delete
 
MemoryAllocatorImploperator= (const MemoryAllocatorImpl &)=delete
 
virtual ~MemoryAllocatorImpl ()
 

Private Member Functions

bool shutdown_ ABSL_GUARDED_BY (reclaimer_mu_)
 
OrphanablePtr< ReclaimerQueue::Handle > reclamation_handles_[kNumReclamationPassesABSL_GUARDED_BY (reclaimer_mu_)
 
template<typename F >
void InsertReclaimer (size_t pass, F fn) ABSL_EXCLUSIVE_LOCKS_REQUIRED(reclaimer_mu_)
 
void MaybeDonateBack ()
 
void MaybeRegisterReclaimer () ABSL_LOCKS_EXCLUDED(reclaimer_mu_)
 
void Replenish ()
 
absl::optional< size_t > TryReserve (MemoryRequest request) GRPC_MUST_USE_RESULT
 

Private Attributes

std::atomic< size_t > free_bytes_ {0}
 
const std::shared_ptr< BasicMemoryQuotamemory_quota_
 
std::string name_
 
Mutex reclaimer_mu_
 
std::atomic< boolregistered_reclaimer_ {false}
 
std::atomic< size_t > taken_bytes_ {sizeof(GrpcMemoryAllocatorImpl)}
 

Detailed Description

Definition at line 285 of file memory_quota.h.

Constructor & Destructor Documentation

◆ GrpcMemoryAllocatorImpl()

grpc_core::GrpcMemoryAllocatorImpl::GrpcMemoryAllocatorImpl ( std::shared_ptr< BasicMemoryQuota memory_quota,
std::string  name 
)
explicit

Definition at line 159 of file memory_quota.cc.

◆ ~GrpcMemoryAllocatorImpl()

grpc_core::GrpcMemoryAllocatorImpl::~GrpcMemoryAllocatorImpl ( )
override

Definition at line 165 of file memory_quota.cc.

Member Function Documentation

◆ ABSL_GUARDED_BY() [1/2]

bool shutdown_ grpc_core::GrpcMemoryAllocatorImpl::ABSL_GUARDED_BY ( reclaimer_mu_  )
private

◆ ABSL_GUARDED_BY() [2/2]

OrphanablePtr<ReclaimerQueue::Handle> reclamation_handles_ [kNumReclamationPasses] grpc_core::GrpcMemoryAllocatorImpl::ABSL_GUARDED_BY ( reclaimer_mu_  )
private

◆ InsertReclaimer()

template<typename F >
void grpc_core::GrpcMemoryAllocatorImpl::InsertReclaimer ( size_t  pass,
fn 
)
inlineprivate

Definition at line 346 of file memory_quota.h.

◆ InstantaneousPressure()

double grpc_core::GrpcMemoryAllocatorImpl::InstantaneousPressure ( ) const
inline

Definition at line 322 of file memory_quota.h.

◆ MaybeDonateBack()

void grpc_core::GrpcMemoryAllocatorImpl::MaybeDonateBack ( )
private

Definition at line 250 of file memory_quota.cc.

◆ MaybeRegisterReclaimer()

void grpc_core::GrpcMemoryAllocatorImpl::MaybeRegisterReclaimer ( )
private

Definition at line 285 of file memory_quota.cc.

◆ name()

absl::string_view grpc_core::GrpcMemoryAllocatorImpl::name ( ) const
inline

Definition at line 328 of file memory_quota.h.

◆ PostReclaimer()

template<typename F >
void grpc_core::GrpcMemoryAllocatorImpl::PostReclaimer ( ReclamationPass  pass,
fn 
)
inline

Definition at line 312 of file memory_quota.h.

◆ Release()

void grpc_core::GrpcMemoryAllocatorImpl::Release ( size_t  n)
inlineoverridevirtual

Release some bytes that were previously reserved. If more bytes are released than were reserved, we will have undefined behavior.

Implements grpc_event_engine::experimental::internal::MemoryAllocatorImpl.

Definition at line 297 of file memory_quota.h.

◆ Replenish()

void grpc_core::GrpcMemoryAllocatorImpl::Replenish ( )
private

Definition at line 270 of file memory_quota.cc.

◆ Reserve()

size_t grpc_core::GrpcMemoryAllocatorImpl::Reserve ( MemoryRequest  request)
overridevirtual

Reserve bytes from the quota. If we enter overcommit, reclamation will begin concurrently. Returns the number of bytes reserved. If MemoryRequest is invalid, this function will abort. If MemoryRequest is valid, this function is infallible, and will always succeed at reserving the some number of bytes between request.min() and request.max() inclusively.

Implements grpc_event_engine::experimental::internal::MemoryAllocatorImpl.

Definition at line 187 of file memory_quota.cc.

◆ Shutdown()

void grpc_core::GrpcMemoryAllocatorImpl::Shutdown ( )
overridevirtual

Shutdown this allocator. Further usage of Reserve() is undefined behavior.

Implements grpc_event_engine::experimental::internal::MemoryAllocatorImpl.

Definition at line 172 of file memory_quota.cc.

◆ TryReserve()

absl::optional< size_t > grpc_core::GrpcMemoryAllocatorImpl::TryReserve ( MemoryRequest  request)
private

Definition at line 203 of file memory_quota.cc.

Member Data Documentation

◆ free_bytes_

std::atomic<size_t> grpc_core::GrpcMemoryAllocatorImpl::free_bytes_ {0}
private

Definition at line 358 of file memory_quota.h.

◆ memory_quota_

const std::shared_ptr<BasicMemoryQuota> grpc_core::GrpcMemoryAllocatorImpl::memory_quota_
private

Definition at line 353 of file memory_quota.h.

◆ name_

std::string grpc_core::GrpcMemoryAllocatorImpl::name_
private

Definition at line 370 of file memory_quota.h.

◆ reclaimer_mu_

Mutex grpc_core::GrpcMemoryAllocatorImpl::reclaimer_mu_
private

Definition at line 362 of file memory_quota.h.

◆ registered_reclaimer_

std::atomic<bool> grpc_core::GrpcMemoryAllocatorImpl::registered_reclaimer_ {false}
private

Definition at line 361 of file memory_quota.h.

◆ taken_bytes_

std::atomic<size_t> grpc_core::GrpcMemoryAllocatorImpl::taken_bytes_ {sizeof(GrpcMemoryAllocatorImpl)}
private

Definition at line 360 of file memory_quota.h.


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


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