UCommon
Public Member Functions
ucommon::paged_reuse< T > Class Template Reference

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

#include <reuse.h>

Inheritance diagram for ucommon::paged_reuse< T >:
Inheritance graph
[legend]
Collaboration diagram for ucommon::paged_reuse< T >:
Collaboration graph
[legend]

Public Member Functions

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

Additional Inherited Members

- Protected Member Functions inherited from ucommon::PagerReuse
bool avail (void) const
 
ReusableObjectget (void)
 
ReusableObjectget (timeout_t timeout)
 
 PagerReuse (mempager *pager, size_t objsize, unsigned count)
 
ReusableObjectrequest (void)
 
- Protected Member Functions inherited from ucommon::MemoryRedirect
virtual void * _alloc (size_t size)
 
 MemoryRedirect (MemoryProtocol *protocol)
 
- Protected Member Functions inherited from ucommon::ReusableAllocator
ReusableObjectnext (ReusableObject *object)
 Get next reusable object in the pool. More...
 
void release (ReusableObject *object)
 Release resuable object. More...
 
 ReusableAllocator ()
 Initialize reusable allocator through a conditional. More...
 
- Protected Member Functions inherited from ucommon::Conditional
void broadcast (void)
 Signal the conditional to release all waiting threads.
 
 Conditional ()
 Initialize and construct conditional.
 
void signal (void)
 Signal the conditional to release one waiting thread.
 
bool wait (timeout_t timeout)
 Conditional wait for signal on millisecond timeout. More...
 
bool wait (struct timespec *timeout)
 Conditional wait for signal on timespec timeout. More...
 
void wait (void)
 Wait (block) until signalled.
 
 ~Conditional ()
 Destroy conditional, release any blocked threads.
 
- Protected Member Functions inherited from ucommon::ConditionMutex
 ConditionMutex ()
 Initialize and construct conditional.
 
void lock (void)
 Lock the conditional's supporting mutex.
 
void unlock (void)
 Unlock the conditional's supporting mutex.
 
 ~ConditionMutex ()
 Destroy conditional, release any blocked threads.
 
- Static Protected Member Functions inherited from ucommon::Conditional
static pthread_condattr_t * initializer (void)
 Support function for getting conditional attributes for realtime scheduling. More...
 
static void set (struct timespec *hires, timeout_t timeout)
 Convert a millisecond timeout into use for high resolution conditional timers. More...
 
- Protected Attributes inherited from ucommon::ReusableAllocator
ReusableObjectfreelist
 
unsigned waiting
 
- Protected Attributes inherited from ucommon::Conditional
pthread_cond_t cond
 
- Protected Attributes inherited from ucommon::ConditionMutex
pthread_mutex_t mutex
 
- Static Protected Attributes inherited from ucommon::Conditional
static attribute attr
 

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 ( 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.

◆ create() [2/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.

◆ get() [1/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.

◆ get() [2/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.

◆ 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:

◆ 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.

◆ 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.

Here is the call graph for this function:

◆ 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: