UCommon
ucommon::paged_reuse< T > Class Template Reference

A reusable private pool of reusable types. More...

#include <reuse.h>

Public Member Functions

T * create (timeout_t timeout)
 Create a typed object from the heap.
 
T * create (void)
 Get a typed object from the pager heap.
 
T * get (timeout_t timeout)
 Get a typed object from the heap.
 
T * get (void)
 Get a typed object from the pager heap.
 
 operator bool () const
 Test if typed objects available from the pager or re-use list.
 
 operator T* ()
 Get a typed object from the pager heap by pointer reference.
 
bool operator! () const
 Test if no objects are available for reuse or the pager.
 
T * operator* ()
 Get a typed object from the pager heap by type casting reference.
 
 paged_reuse (mempager *pager, unsigned count)
 Create a managed reusable typed object pool.
 
void release (T *object)
 Release (return) a typed object back to the pager heap for re-use.
 
T * request (void)
 Request immediately next available typed object from the pager heap.
 

Detailed Description

template<class T>
class ucommon::paged_reuse< T >

A reusable private pool of reusable types.

A pool of typed objects is created which can be allocated from a memory pager. Deallocated typed objects are also returned to this pool so they can be reallocated later.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 221 of file reuse.h.

Constructor & Destructor Documentation

◆ paged_reuse()

template<class T >
ucommon::paged_reuse< T >::paged_reuse ( mempager * pager,
unsigned count )
inline

Create a managed reusable typed object pool.

This manages a heap of typed objects that can either be reused from released objects or allocate from an existing memory pager pool.

Parameters
pagerpool to allocate from.
countof objects of specified type to allocate.

Definition at line 234 of file reuse.h.

Member Function Documentation

◆ create() [1/2]

template<class T >
T * ucommon::paged_reuse< T >::create ( timeout_t timeout)
inline

Create a typed object from the heap.

This function blocks until the the heap has an object to return or the timer has expired. The objects default constructor is used.

Parameters
timeoutto wait for heap in milliseconds.
Returns
typed object pointer from heap or NULL if timeout.

Definition at line 289 of file reuse.h.

Here is the call graph for this function:

◆ create() [2/2]

template<class T >
T * ucommon::paged_reuse< T >::create ( void )
inline

Get a typed object from the pager heap.

This function blocks when the heap is empty until an object is returned to the heap. The objects default constructor is used.

Returns
typed object pointer from heap.

Definition at line 268 of file reuse.h.

Here is the call graph for this function:

◆ get() [1/2]

template<class T >
T * ucommon::paged_reuse< T >::get ( timeout_t timeout)
inline

Get a typed object from the heap.

This function blocks until the the heap has an object to return or the timer has expired.

Parameters
timeoutto wait for heap in milliseconds.
Returns
typed object pointer from heap or NULL if timeout.

Definition at line 278 of file reuse.h.

◆ get() [2/2]

template<class T >
T * ucommon::paged_reuse< T >::get ( void )
inline

Get a typed object from the pager heap.

This function blocks when the heap is empty until an object is returned to the heap.

Returns
typed object pointer from heap.

Definition at line 258 of file reuse.h.

◆ operator bool()

template<class T >
ucommon::paged_reuse< T >::operator bool ( ) const
inline

Test if typed objects available from the pager or re-use list.

Returns
true if objects still are available.

Definition at line 241 of file reuse.h.

◆ operator T*()

template<class T >
ucommon::paged_reuse< T >::operator T* ( )
inline

Get a typed object from the pager heap by pointer reference.

This function blocks while the heap is empty.

Returns
typed object pointer from heap.

Definition at line 323 of file reuse.h.

Here is the call graph for this function:

◆ operator!()

template<class T >
bool ucommon::paged_reuse< T >::operator! ( ) const
inline

Test if no objects are available for reuse or the pager.

Returns
true if no objects are available.

Definition at line 249 of file reuse.h.

◆ operator*()

template<class T >
T * ucommon::paged_reuse< T >::operator* ( )
inline

Get a typed object from the pager heap by type casting reference.

This function blocks while the heap is empty.

Returns
typed object pointer from heap.

Definition at line 314 of file reuse.h.

Here is the call graph for this function:

◆ release()

template<class T >
void ucommon::paged_reuse< T >::release ( T * object)
inline

Release (return) a typed object back to the pager heap for re-use.

Parameters
objectto return.

Definition at line 305 of file reuse.h.

◆ request()

template<class T >
T * ucommon::paged_reuse< T >::request ( void )
inline

Request immediately next available typed object from the pager heap.

Returns
typed object pointer or NULL if heap is empty.

Definition at line 297 of file reuse.h.


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