VLink  2.0.0
A high-performance communication middleware
vlink::ObjectPoolBase类 参考

Type-independent base of ObjectPool that owns counters, mutex and policy state. 更多...

#include <object_pool.h>

类 vlink::ObjectPoolBase 继承关系图:
vlink::ObjectPoolBase 的协作图:

struct  Stats
 Point-in-time snapshot of internal pool counters. 更多...
 

Public 类型

enum  Policy : uint8_t { kPolicyNone = 0 , kPolicyRelease = 1 , kPolicyAcquire = 2 , kPolicyBoth = 3 }
 Decides when (or whether) the user-supplied ResetCallback runs. 更多...
 

Public 成员函数

size_t borrowed () const
 Returns the number of objects currently checked out of the pool. 更多...
 
size_t total_created () const
 Returns the cumulative number of objects ever produced by the factory. 更多...
 
size_t max_size () const noexcept
 Returns the configured upper bound on live objects. 更多...
 

Protected 成员函数

 ObjectPoolBase (size_t max_size, size_t initial_size, Policy policy)
 
 ~ObjectPoolBase () noexcept=default
 
void safe_dec_borrowed_and_live () noexcept
 
bool should_reset_on_acquire () const noexcept
 
bool should_reset_on_release () const noexcept
 
void throw_exhausted (size_t pool_size) const
 

静态 Protected 成员函数

static void throw_invalid_size ()
 
static void throw_factory_null_pre_fill ()
 
static void throw_factory_null ()
 

Protected 属性

Policy policy_ {kPolicyNone}
 
size_t max_size_ {0}
 
std::mutex mutex_
 
size_t borrowed_ {0}
 
size_t live_count_ {0}
 
size_t total_created_ {0}
 

详细描述

Type-independent base of ObjectPool that owns counters, mutex and policy state.

Keeps the shared bookkeeping for ObjectPool<T> in a single translation unit so that cold-path validation and error-throwing helpers do not need to be re-instantiated for every element type. Element storage and callbacks remain in the derived template.

成员枚举类型说明

◆ Policy

Decides when (or whether) the user-supplied ResetCallback runs.

Reset failures on the release path are caught and the offending object is dropped from the pool instead of being recycled. Failures on the acquire path are rethrown after the object has been put back on the free list.

枚举值
kPolicyNone 

Never invoke the reset callback.

kPolicyRelease 

Reset on the return-to-pool path.

kPolicyAcquire 

Reset on the hand-out-to-caller path.

kPolicyBoth 

Reset on both paths.

构造及析构函数说明

◆ ObjectPoolBase()

vlink::ObjectPoolBase::ObjectPoolBase ( size_t  max_size,
size_t  initial_size,
Policy  policy 
)
protected

◆ ~ObjectPoolBase()

vlink::ObjectPoolBase::~ObjectPoolBase ( )
protecteddefaultnoexcept

成员函数说明

◆ borrowed()

size_t vlink::ObjectPoolBase::borrowed ( ) const

Returns the number of objects currently checked out of the pool.

返回
Borrowed object count.

◆ max_size()

size_t vlink::ObjectPoolBase::max_size ( ) const
noexcept

Returns the configured upper bound on live objects.

返回
Maximum size; 0 means unlimited.

◆ safe_dec_borrowed_and_live()

void vlink::ObjectPoolBase::safe_dec_borrowed_and_live ( )
protectednoexcept

◆ should_reset_on_acquire()

bool vlink::ObjectPoolBase::should_reset_on_acquire ( ) const
protectednoexcept

◆ should_reset_on_release()

bool vlink::ObjectPoolBase::should_reset_on_release ( ) const
protectednoexcept
这是这个函数的调用关系图:

◆ throw_exhausted()

void vlink::ObjectPoolBase::throw_exhausted ( size_t  pool_size) const
protected

◆ throw_factory_null()

static void vlink::ObjectPoolBase::throw_factory_null ( )
staticprotected

◆ throw_factory_null_pre_fill()

static void vlink::ObjectPoolBase::throw_factory_null_pre_fill ( )
staticprotected
这是这个函数的调用关系图:

◆ throw_invalid_size()

static void vlink::ObjectPoolBase::throw_invalid_size ( )
staticprotected

◆ total_created()

size_t vlink::ObjectPoolBase::total_created ( ) const

Returns the cumulative number of objects ever produced by the factory.

返回
Total created count.

类成员变量说明

◆ borrowed_

size_t vlink::ObjectPoolBase::borrowed_ {0}
protected

◆ live_count_

size_t vlink::ObjectPoolBase::live_count_ {0}
protected

◆ max_size_

size_t vlink::ObjectPoolBase::max_size_ {0}
protected

◆ mutex_

std::mutex vlink::ObjectPoolBase::mutex_
mutableprotected

◆ policy_

Policy vlink::ObjectPoolBase::policy_ {kPolicyNone}
protected

◆ total_created_

size_t vlink::ObjectPoolBase::total_created_ {0}
protected

该类的文档由以下文件生成: