An array of reusable types.
More...
#include <reuse.h>
|
| array_reuse (unsigned count) |
| Create private heap of reusable objects of specified type. More...
|
|
| array_reuse (unsigned count, void *memory) |
| Create reusable objects of specific type in preallocated memory. More...
|
|
T * | create (void) |
| Create a typed object from the heap. More...
|
|
T * | create (timeout_t timeout) |
| Create a typed object from the heap. More...
|
|
T * | get (void) |
| Get a typed object from the heap. More...
|
|
T * | get (timeout_t timeout) |
| Get a typed object from the heap. More...
|
|
T * | operator * () |
| Get a typed object from the heap by pointer reference. More...
|
|
| operator bool () const |
| Test if typed objects available in heap or re-use list. More...
|
|
| operator T * () |
| Get a typed object from the heap by type casting reference. More...
|
|
bool | operator! () const |
| Test if the entire heap has been allocated. More...
|
|
void | release (T *object) |
| Release (return) a typed object back to the heap for re-use. More...
|
|
T * | request (void) |
| Request immediately next available typed object from the heap. More...
|
|
|
| ArrayReuse (size_t objsize, unsigned c) |
|
| ArrayReuse (size_t objsize, unsigned c, void *memory) |
|
bool | avail (void) const |
|
ReusableObject * | get (timeout_t timeout) |
|
ReusableObject * | get (void) |
|
ReusableObject * | request (void) |
|
| ~ArrayReuse () |
| Destroy reusable private heap array.
|
|
ReusableObject * | next (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...
|
|
void | broadcast (void) |
| Signal the conditional to release all waiting threads.
|
|
| Conditional () |
| Initialize and construct conditional.
|
|
void | signal (void) |
| Signal the conditional to release one waiting thread.
|
|
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.
|
|
| ConditionMutex () |
| Initialize and construct conditional.
|
|
void | lock (void) |
| Lock the conditional's supporting mutex.
|
|
void | unlock (void) |
| Unlock the conditional's supporting mutex.
|
|
| ~ConditionMutex () |
| Destroy conditional, release any blocked threads.
|
|
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...
|
|
ReusableObject * | freelist |
|
unsigned | waiting |
|
pthread_cond_t | cond |
|
pthread_mutex_t | mutex |
|
static attribute | attr |
|
template<class T>
class ucommon::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.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 104 of file reuse.h.
◆ array_reuse() [1/2]
Create private heap of reusable objects of specified type.
- Parameters
-
count | of objects of specified type to allocate. |
Definition at line 114 of file reuse.h.
◆ array_reuse() [2/2]
Create reusable objects of specific type in preallocated memory.
- Parameters
-
count | of objects of specified type in memory. |
memory | to use. |
Definition at line 122 of file reuse.h.
◆ create() [1/2]
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 163 of file reuse.h.
◆ create() [2/2]
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
-
timeout | to wait for heap in milliseconds. |
- Returns
- typed object pointer from heap or NULL if timeout.
Definition at line 183 of file reuse.h.
◆ get() [1/2]
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.
Definition at line 154 of file reuse.h.
◆ get() [2/2]
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.
Definition at line 173 of file reuse.h.
◆ operator *()
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 209 of file reuse.h.
◆ operator bool()
Test if typed objects available in heap or re-use list.
- Returns
- true if objects still are available.
Definition at line 129 of file reuse.h.
◆ operator T *()
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 200 of file reuse.h.
◆ operator!()
Test if the entire heap has been allocated.
- Returns
- true if no objects are available.
Definition at line 137 of file reuse.h.
◆ release()
Release (return) a typed object back to the heap for re-use.
- Parameters
-
Definition at line 191 of file reuse.h.
◆ request()
Request immediately next available typed object from the heap.
- Returns
- typed object pointer or NULL if heap is empty.
Definition at line 145 of file reuse.h.
The documentation for this class was generated from the following file: