UCommon

paged_reuse< T > Class Template Reference

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

#include <vector.h>

Inheritance diagram for paged_reuse< T >:
Collaboration diagram for paged_reuse< T >:

Public Member Functions

T * create (void)
 Get a typed object from the pager heap.
T * create (timeout_t timeout)
 Create a typed object from the heap.
T * get (void)
 Get a typed object from the pager heap.
T * get (timeout_t timeout)
 Get a typed object from the 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 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>
Examples:

queue.cpp.

Definition at line 584 of file vector.h.


Constructor & Destructor Documentation

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


Member Function Documentation

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

Here is the call graph for this function:

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

Here is the call graph for this function:

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

Definition at line 616 of file vector.h.

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

Reimplemented from PagerReuse.

Definition at line 634 of file vector.h.

Here is the call graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

template<class T>
void 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 658 of file vector.h.

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

Definition at line 651 of file vector.h.


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