UCommon
|
Class for resource bound memory pools between threads. More...
#include <thread.h>
Protected Member Functions | |
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. | |
Protected Attributes | |
ReusableObject * | freelist |
unsigned | waiting |
![]() | |
pthread_cond_t | cond |
![]() | |
pthread_mutex_t | mutex |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
static attribute | attr |
Class for resource bound memory pools between threads.
This is used to support a memory pool allocation scheme where a pool of reusable objects may be allocated, and the pool renewed by releasing objects or back. When the pool is used up, a pool consuming thread then must wait for a resource to be freed by another consumer (or timeout). This class is not meant to be used directly, but rather to build the synchronizing control between consumers which might be forced to wait for a resource.
|
protected |
Initialize reusable allocator through a conditional.
Zero free list.
|
inlineprotected |
|
protected |
Release resuable object.
object | being released. |