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

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

#include <vector.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...
 
 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...
 
T * operator* ()
 Get a typed object from the pager heap by type casting reference. 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)
 
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::MemoryProtocol
virtual void * _alloc (size_t size)=0
 Protocol to allocate memory from the pager heap. More...
 
virtual void fault (void) const
 Allocation failure handler.
 
void * alloc (size_t size)
 Convenience function. More...
 
char * dup (const char *string)
 Duplicate NULL terminated string into allocated memory. More...
 
void * dup (void *memory, size_t size)
 Duplicate existing memory block into allocated memory. More...
 
void * zalloc (size_t size)
 Allocate memory from the pager heap. More...
 
- 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 lock (void)
 Lock the conditional's supporting mutex.
 
void signal (void)
 Signal the conditional to release one waiting thread.
 
void unlock (void)
 Unlock the conditional's supporting mutex.
 
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.
 
- 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
 

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 595 of file vector.h.

Constructor & Destructor Documentation

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 605 of file vector.h.

Member Function Documentation

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 636 of file vector.h.

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 655 of file vector.h.

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 627 of file vector.h.

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 645 of file vector.h.

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 612 of file vector.h.

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 685 of file vector.h.

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 619 of file vector.h.

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 677 of file vector.h.

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 669 of file vector.h.

Here is the call graph for this function:

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 662 of file vector.h.


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