PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
kcenon::pacs::network::tracked_pdu_pool< T > Class Template Reference

Pool wrapper with statistics tracking for PDU buffers. More...

#include <pdu_buffer_pool.h>

Inheritance diagram for kcenon::pacs::network::tracked_pdu_pool< T >:
Inheritance graph
Collaboration diagram for kcenon::pacs::network::tracked_pdu_pool< T >:
Collaboration graph

Public Types

using pool_type = kcenon::common::utils::ObjectPool<T>
 
using unique_ptr_type = std::unique_ptr<T, std::function<void(T*)>>
 

Public Member Functions

 tracked_pdu_pool (std::size_t initial_size=64)
 
template<typename... Args>
auto acquire (Args &&... args) -> unique_ptr_type
 Acquire an object from the pool.
 
auto statistics () const noexcept -> const pdu_pool_statistics &
 Get the pool statistics.
 
auto available () const -> std::size_t
 Get the number of available objects in the pool.
 
void reserve (std::size_t count)
 Reserve additional capacity in the pool.
 
void clear ()
 Clear the pool and release all memory.
 

Private Attributes

pool_type pool_
 
pdu_pool_statistics stats_
 

Detailed Description

template<typename T>
class kcenon::pacs::network::tracked_pdu_pool< T >

Pool wrapper with statistics tracking for PDU buffers.

Template Parameters
TThe type of objects to pool

Definition at line 165 of file pdu_buffer_pool.h.

Member Typedef Documentation

◆ pool_type

template<typename T >
using kcenon::pacs::network::tracked_pdu_pool< T >::pool_type = kcenon::common::utils::ObjectPool<T>

◆ unique_ptr_type

template<typename T >
using kcenon::pacs::network::tracked_pdu_pool< T >::unique_ptr_type = std::unique_ptr<T, std::function<void(T*)>>

Constructor & Destructor Documentation

◆ tracked_pdu_pool()

template<typename T >
kcenon::pacs::network::tracked_pdu_pool< T >::tracked_pdu_pool ( std::size_t initial_size = 64)
inlineexplicit

Member Function Documentation

◆ acquire()

template<typename T >
template<typename... Args>
auto kcenon::pacs::network::tracked_pdu_pool< T >::acquire ( Args &&... args) -> unique_ptr_type
inline

Acquire an object from the pool.

Parameters
argsArguments forwarded to the object's constructor
Returns
A unique_ptr that returns the object to the pool on destruction
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pdu_buffer_pool.h.

Definition at line 181 of file pdu_buffer_pool.h.

181 {
182 bool reused = false;
183 auto ptr = pool_.acquire(&reused, std::forward<Args>(args)...);
184
185 stats_.total_acquisitions.fetch_add(1, std::memory_order_relaxed);
186 if (reused) {
187 stats_.pool_hits.fetch_add(1, std::memory_order_relaxed);
188 } else {
189 stats_.pool_misses.fetch_add(1, std::memory_order_relaxed);
190 }
191
192 return ptr;
193 }

References kcenon::pacs::network::tracked_pdu_pool< T >::pool_, kcenon::pacs::network::pdu_pool_statistics::pool_hits, kcenon::pacs::network::pdu_pool_statistics::pool_misses, kcenon::pacs::network::tracked_pdu_pool< T >::stats_, and kcenon::pacs::network::pdu_pool_statistics::total_acquisitions.

◆ available()

template<typename T >
auto kcenon::pacs::network::tracked_pdu_pool< T >::available ( ) const -> std::size_t
inlinenodiscard

Get the number of available objects in the pool.

Returns
Available object count
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pdu_buffer_pool.h.

Definition at line 207 of file pdu_buffer_pool.h.

207 {
208 return pool_.available();
209 }

References kcenon::pacs::network::tracked_pdu_pool< T >::pool_.

◆ clear()

template<typename T >
void kcenon::pacs::network::tracked_pdu_pool< T >::clear ( )
inline

Clear the pool and release all memory.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pdu_buffer_pool.h.

Definition at line 222 of file pdu_buffer_pool.h.

222 {
223 pool_.clear();
224 }

References kcenon::pacs::network::tracked_pdu_pool< T >::pool_.

◆ reserve()

template<typename T >
void kcenon::pacs::network::tracked_pdu_pool< T >::reserve ( std::size_t count)
inline

Reserve additional capacity in the pool.

Parameters
countNumber of objects to pre-allocate
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pdu_buffer_pool.h.

Definition at line 215 of file pdu_buffer_pool.h.

215 {
216 pool_.reserve(count);
217 }

References kcenon::pacs::network::tracked_pdu_pool< T >::pool_.

◆ statistics()

template<typename T >
auto kcenon::pacs::network::tracked_pdu_pool< T >::statistics ( ) const -> const pdu_pool_statistics&
inlinenodiscardnoexcept

Get the pool statistics.

Returns
Reference to the statistics
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pdu_buffer_pool.h.

Definition at line 199 of file pdu_buffer_pool.h.

199 {
200 return stats_;
201 }

References kcenon::pacs::network::tracked_pdu_pool< T >::stats_.

Member Data Documentation

◆ pool_

◆ stats_


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