22#include <kcenon/common/utils/object_pool.h>
47 [[nodiscard]]
auto hit_ratio() const noexcept ->
double {
52 return static_cast<double>(
pool_hits.load(std::memory_order_relaxed))
53 /
static_cast<double>(total);
61 pool_hits.store(0, std::memory_order_relaxed);
74 using pool_type = kcenon::common::utils::ObjectPool<T>;
78 :
pool_(initial_size) {
79 pool_.reserve(initial_size);
87 template <
typename... Args>
90 auto ptr =
pool_.acquire(&reused, std::forward<Args>(args)...);
115 return pool_.available();
123 pool_.reserve(count);
260 std::string_view value)
263 elem->set_string(value);
void reset_statistics()
Reset all statistics.
static constexpr std::size_t DEFAULT_DATASET_POOL_SIZE
tracked_pool< dicom_element > element_pool_
void clear_all()
Clear all pools.
auto element_statistics() const noexcept -> const pool_statistics &
Get element pool statistics.
auto acquire_element(dicom_tag tag, encoding::vr_type vr) -> tracked_pool< dicom_element >::unique_ptr_type
Acquire a dicom_element from the pool.
void reserve_elements(std::size_t count)
Reserve capacity in element pool.
static auto get() noexcept -> pool_manager &
Get the thread-local pool manager instance.
static constexpr std::size_t DEFAULT_ELEMENT_POOL_SIZE
Default pool sizes.
void reserve_datasets(std::size_t count)
Reserve capacity in dataset pool.
auto dataset_statistics() const noexcept -> const pool_statistics &
Get dataset pool statistics.
auto acquire_dataset() -> tracked_pool< dicom_dataset >::unique_ptr_type
Acquire a dicom_dataset from the pool.
tracked_pool< dicom_dataset > dataset_pool_
Pool wrapper with statistics tracking.
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.
auto statistics() const noexcept -> const pool_statistics &
Get the pool statistics.
kcenon::common::utils::ObjectPool< T > pool_type
tracked_pool(std::size_t initial_size=32)
auto acquire(Args &&... args) -> unique_ptr_type
Acquire an object from the pool.
std::unique_ptr< T, std::function< void(T *)> > unique_ptr_type
DICOM Dataset - ordered collection of Data Elements.
DICOM Data Element representation (Tag, VR, Value)
auto make_pooled_element(dicom_tag tag, encoding::vr_type vr) -> tracked_pool< dicom_element >::unique_ptr_type
Create a pooled dicom_element.
auto make_pooled_dataset() -> tracked_pool< dicom_dataset >::unique_ptr_type
Create a pooled dicom_dataset.
vr_type
DICOM Value Representation (VR) types.
Statistics for object pool usage monitoring.
std::atomic< uint64_t > total_releases
std::atomic< uint64_t > total_acquisitions
void reset() noexcept
Reset all statistics.
std::atomic< uint64_t > pool_hits
std::atomic< uint64_t > pool_misses
auto hit_ratio() const noexcept -> double
Calculate hit ratio (0.0 to 1.0)