ucc::paged_reuse< T > Class Template Reference

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

#include <vector.h>

Inheritance diagram for ucc::paged_reuse< T >:

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

Collaboration graph
[legend]

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 ucc::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@gnutelephony.org>

Definition at line 584 of file vector.h.


Constructor & Destructor Documentation

template<class T>
ucc::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:
pager pool to allocate from.
count of objects of specified type to allocate.

Definition at line 594 of file vector.h.


Member Function Documentation

template<class T>
T* ucc::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:
timeout to wait for heap in milliseconds.
Returns:
typed object pointer from heap or NULL if timeout.

Definition at line 644 of file vector.h.

template<class T>
T* ucc::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 625 of file vector.h.

template<class T>
T* ucc::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:
timeout to wait for heap in milliseconds.
Returns:
typed object pointer from heap or NULL if timeout.

Reimplemented from ucc::PagerReuse.

Definition at line 634 of file vector.h.

template<class T>
T* ucc::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.

Reimplemented from ucc::PagerReuse.

Definition at line 616 of file vector.h.

template<class T>
ucc::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 601 of file vector.h.

template<class T>
ucc::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 674 of file vector.h.

template<class T>
bool ucc::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 608 of file vector.h.

template<class T>
T* ucc::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 666 of file vector.h.

template<class T>
void ucc::paged_reuse< T >::release ( T *  object  )  [inline]

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

Parameters:
object to return.

Definition at line 658 of file vector.h.

Here is the call graph for this function:

template<class T>
T* ucc::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.

Reimplemented from ucc::PagerReuse.

Definition at line 651 of file vector.h.


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

Generated on Tue May 17 12:15:38 2011 for UCommon by  doxygen 1.5.6