UCommon
Public Member Functions
ucommon::array_reuse Class Reference

An array of reusable types. More...

#include <vector.h>

Inheritance diagram for ucommon::array_reuse:
Inheritance graph
[legend]
Collaboration diagram for ucommon::array_reuse:
Collaboration graph
[legend]

Public Member Functions

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

Detailed Description

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>

Constructor & Destructor Documentation

ucommon::array_reuse::array_reuse ( unsigned  count) [inline]

Create private heap of reusable objects of specified type.

Parameters:
countof objects of specified type to allocate.

Definition at line 495 of file vector.h.


Member Function Documentation

T* ucommon::array_reuse::create ( void  ) [inline]

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

Definition at line 532 of file vector.h.

T* ucommon::array_reuse::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.

Parameters:
timeoutto wait for heap in milliseconds.
Returns:
typed object pointer from heap or NULL if timeout.

Definition at line 550 of file vector.h.

T* ucommon::array_reuse::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 ucommon::ArrayReuse.

Definition at line 524 of file vector.h.

T* ucommon::array_reuse::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 ucommon::ArrayReuse.

Definition at line 541 of file vector.h.

ucommon::array_reuse::operator bool ( ) const [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.

ucommon::array_reuse::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 565 of file vector.h.

bool ucommon::array_reuse::operator! ( ) const [inline]

Test if the entire heap has been allocated.

Returns:
true if no objects are available.

Definition at line 509 of file vector.h.

T* ucommon::array_reuse::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 573 of file vector.h.

void ucommon::array_reuse::release ( T *  object) [inline]

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

Parameters:
objectto return.

Definition at line 557 of file vector.h.

Here is the call graph for this function:

T* ucommon::array_reuse::request ( void  ) [inline]

Request immediately next available typed object from the heap.

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

Reimplemented from ucommon::ArrayReuse.

Definition at line 516 of file vector.h.


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