NCBI C++ ToolKit
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ncbi::TResourcePool< _T > Class Template Reference

Search Toolkit Book for ncbi::TResourcePool

#include <objtools/writers/atomics.hpp>

+ Collaboration diagram for ncbi::TResourcePool< _T >:

Classes

struct  TDeleter
 

Public Types

using _MyType = TResourcePool< _T >
 
using value_type = _T
 
using TStack = TAtomicStack< value_type >
 
using TNode = typename TStack::TNode
 
using init_func = std::function< void(value_type &)>
 
using TUniqPointer = std::unique_ptr< TNode, TDeleter >
 

Public Member Functions

 TResourcePool ()=default
 
 TResourcePool (size_t _reserved)
 
 TResourcePool (size_t _reserved, init_func _init, init_func _deinit)
 
 ~TResourcePool ()
 
void SetInitFunc (init_func _init, init_func _deinit)
 
TUniqPointer Allocate ()
 
void SetReserved (size_t num)
 
size_t size () const
 
void Purge ()
 

Protected Member Functions

void Deallocate (TNode *ptr)
 

Protected Attributes

TStack m_stack
 
init_func m_init
 
init_func m_deinit
 
std::atomic< size_t > m_size {0}
 
std::atomic< size_t > m_reserved_size {std::numeric_limits<size_t>::max()}
 

Friends

struct TDeleter
 

Detailed Description

template<typename _T>
class ncbi::TResourcePool< _T >

Definition at line 112 of file atomics.hpp.

Member Typedef Documentation

◆ _MyType

template<typename _T >
using ncbi::TResourcePool< _T >::_MyType = TResourcePool<_T>

Definition at line 119 of file atomics.hpp.

◆ init_func

template<typename _T >
using ncbi::TResourcePool< _T >::init_func = std::function<void(value_type&)>

Definition at line 124 of file atomics.hpp.

◆ TNode

template<typename _T >
using ncbi::TResourcePool< _T >::TNode = typename TStack::TNode

Definition at line 123 of file atomics.hpp.

◆ TStack

template<typename _T >
using ncbi::TResourcePool< _T >::TStack = TAtomicStack<value_type>

Definition at line 122 of file atomics.hpp.

◆ TUniqPointer

template<typename _T >
using ncbi::TResourcePool< _T >::TUniqPointer = std::unique_ptr<TNode, TDeleter>

Definition at line 127 of file atomics.hpp.

◆ value_type

template<typename _T >
using ncbi::TResourcePool< _T >::value_type = _T

Definition at line 120 of file atomics.hpp.

Constructor & Destructor Documentation

◆ TResourcePool() [1/3]

template<typename _T >
ncbi::TResourcePool< _T >::TResourcePool ( )
default

◆ TResourcePool() [2/3]

template<typename _T >
ncbi::TResourcePool< _T >::TResourcePool ( size_t  _reserved)
inline

Definition at line 131 of file atomics.hpp.

◆ TResourcePool() [3/3]

template<typename _T >
ncbi::TResourcePool< _T >::TResourcePool ( size_t  _reserved,
init_func  _init,
init_func  _deinit 
)
inline

Definition at line 132 of file atomics.hpp.

References ncbi::TResourcePool< _T >::SetReserved().

◆ ~TResourcePool()

template<typename _T >
ncbi::TResourcePool< _T >::~TResourcePool ( )
inline

Definition at line 139 of file atomics.hpp.

References ncbi::TResourcePool< _T >::Purge().

Member Function Documentation

◆ Allocate()

template<typename _T >
TUniqPointer ncbi::TResourcePool< _T >::Allocate ( )
inline

◆ Deallocate()

template<typename _T >
void ncbi::TResourcePool< _T >::Deallocate ( TNode ptr)
inlineprotected

◆ Purge()

template<typename _T >
void ncbi::TResourcePool< _T >::Purge ( )
inline

◆ SetInitFunc()

template<typename _T >
void ncbi::TResourcePool< _T >::SetInitFunc ( init_func  _init,
init_func  _deinit 
)
inline

◆ SetReserved()

template<typename _T >
void ncbi::TResourcePool< _T >::SetReserved ( size_t  num)
inline

◆ size()

template<typename _T >
size_t ncbi::TResourcePool< _T >::size ( void  ) const
inline

Definition at line 170 of file atomics.hpp.

References ncbi::TResourcePool< _T >::m_size.

Friends And Related Function Documentation

◆ TDeleter

template<typename _T >
friend struct TDeleter
friend

Definition at line 115 of file atomics.hpp.

Member Data Documentation

◆ m_deinit

template<typename _T >
init_func ncbi::TResourcePool< _T >::m_deinit
protected

◆ m_init

template<typename _T >
init_func ncbi::TResourcePool< _T >::m_init
protected

◆ m_reserved_size

template<typename _T >
std::atomic<size_t> ncbi::TResourcePool< _T >::m_reserved_size {std::numeric_limits<size_t>::max()}
protected

◆ m_size

template<typename _T >
std::atomic<size_t> ncbi::TResourcePool< _T >::m_size {0}
protected

◆ m_stack

template<typename _T >
TStack ncbi::TResourcePool< _T >::m_stack
protected

The documentation for this class was generated from the following file:
Modified on Sun Feb 25 03:08:37 2024 by modify_doxy.py rev. 669887