|
VLink
2.0.0
A high-performance communication middleware
|
Type-independent base of ObjectPool that owns counters, mutex and policy state.
More...
#include <object_pool.h>
Classes | |
| struct | Stats |
| Point-in-time snapshot of internal pool counters. More... | |
Public Types | |
| enum | Policy : uint8_t { kPolicyNone = 0 , kPolicyRelease = 1 , kPolicyAcquire = 2 , kPolicyBoth = 3 } |
Decides when (or whether) the user-supplied ResetCallback runs. More... | |
Public Member Functions | |
| size_t | borrowed () const |
| Returns the number of objects currently checked out of the pool. More... | |
| size_t | total_created () const |
| Returns the cumulative number of objects ever produced by the factory. More... | |
| size_t | max_size () const noexcept |
| Returns the configured upper bound on live objects. More... | |
Protected Member Functions | |
| 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 |
Static Protected Member Functions | |
| static void | throw_invalid_size () |
| static void | throw_factory_null_pre_fill () |
| static void | throw_factory_null () |
Protected Attributes | |
| 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.
| enum vlink::ObjectPoolBase::Policy : uint8_t |
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.
| Enumerator | |
|---|---|
| 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. |
|
protected |
|
protecteddefaultnoexcept |
| size_t vlink::ObjectPoolBase::borrowed | ( | ) | const |
Returns the number of objects currently checked out of the pool.
|
noexcept |
Returns the configured upper bound on live objects.
0 means unlimited.
|
protectednoexcept |
|
protectednoexcept |
|
protectednoexcept |
|
protected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
| size_t vlink::ObjectPoolBase::total_created | ( | ) | const |
Returns the cumulative number of objects ever produced by the factory.
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |