ucc::array_reuse< T > Class Template Reference

An array of reusable types. More...

#include <vector.h>

Inheritance diagram for ucc::array_reuse< T >:

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

Collaboration graph
[legend]

Public Member Functions

 array_reuse (unsigned count)
 Create private heap of reusable objects of specified type.
 operator bool ()
 Test if typed objects available in heap or re-use list.
bool operator! ()
 Test if the entire heap has been allocated.
T * request (void)
 Request immediately next available typed object from the heap.
T * get (void)
 Get a typed object from the heap.
T * get (timeout_t timeout)
 Get a typed object from the heap.
void release (T *object)
 Release (return) a typed object back to the heap for re-use.
 operator T * ()
 Get a typed object from the heap by type casting reference.
T * operator* ()
 Get a typed object from the heap by pointer reference.

Detailed Description

template<class T>
class ucc::array_reuse< T >

An array of reusable types.

A pool of typed objects is created which can be allocated as needed. Deallocated typed objects are returned to the pool so they can be reallocated later. This is a private fixed size heap.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 488 of file vector.h.


Constructor & Destructor Documentation

template<class T >
ucc::array_reuse< T >::array_reuse ( unsigned  count  )  [inline]

Create private heap of reusable objects of specified type.

Parameters:
count of objects of specified type to allocate.

Definition at line 495 of file vector.h.


Member Function Documentation

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

Definition at line 533 of file vector.h.

template<class T >
T* ucc::array_reuse< T >::get ( void   )  [inline]

Get a typed object from the 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::ArrayReuse.

Definition at line 524 of file vector.h.

template<class T >
ucc::array_reuse< T >::operator bool (  )  [inline]

Test if typed objects available in heap or re-use list.

Returns:
true if objects still are available.

Definition at line 502 of file vector.h.

template<class T >
ucc::array_reuse< T >::operator T * (  )  [inline]

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

This function blocks while the heap is empty.

Returns:
typed object pointer from heap.

Definition at line 548 of file vector.h.

template<class T >
bool ucc::array_reuse< T >::operator! (  )  [inline]

Test if the entire heap has been allocated.

Returns:
true if no objects are available.

Definition at line 509 of file vector.h.

template<class T >
T* ucc::array_reuse< T >::operator* (  )  [inline]

Get a typed object from the heap by pointer reference.

This function blocks while the heap is empty.

Returns:
typed object pointer from heap.

Definition at line 556 of file vector.h.

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

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

Parameters:
object to return.

Definition at line 540 of file vector.h.

Here is the call graph for this function:

template<class T >
T* ucc::array_reuse< T >::request ( void   )  [inline]

Request immediately next available typed object from the heap.

Returns:
typed object pointer or NULL if heap is empty.

Reimplemented from ucc::ArrayReuse.

Definition at line 516 of file vector.h.


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

Generated on Tue Jul 28 21:43:43 2009 for UCommon by  doxygen 1.5.9