UCommon
ucommon::ReusableAllocator Class Reference

Class for resource bound memory pools between threads. More...

#include <thread.h>

Inheritance diagram for ucommon::ReusableAllocator:
Collaboration diagram for ucommon::ReusableAllocator:

Protected Member Functions

ReusableObjectnext (ReusableObject *object)
 Get next reusable object in the pool.
 
void release (ReusableObject *object)
 Release resuable object.
 
 ReusableAllocator ()
 Initialize reusable allocator through a conditional.
 
- Protected Member Functions inherited from ucommon::Conditional
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 (struct timespec *timeout)
 Conditional wait for signal on timespec timeout.
 
bool wait (timeout_t timeout)
 Conditional wait for signal on millisecond timeout.
 
void wait (void)
 Wait (block) until signalled.
 
 ~Conditional ()
 Destroy conditional, release any blocked threads.
 
- Protected Member Functions inherited from ucommon::ConditionMutex
 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

ReusableObjectfreelist
 
unsigned waiting
 
- Protected Attributes inherited from ucommon::Conditional
pthread_cond_t cond
 
- Protected Attributes inherited from ucommon::ConditionMutex
pthread_mutex_t mutex
 

Additional Inherited Members

- Static Protected Member Functions inherited from ucommon::Conditional
static pthread_condattr_t * initializer (void)
 Support function for getting conditional attributes for realtime scheduling.
 
static void set (struct timespec *hires, timeout_t timeout)
 Convert a millisecond timeout into use for high resolution conditional timers.
 
- Static Protected Attributes inherited from ucommon::Conditional
static attribute attr
 

Detailed Description

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.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 416 of file thread.h.

Constructor & Destructor Documentation

◆ ReusableAllocator()

ucommon::ReusableAllocator::ReusableAllocator ( )
protected

Initialize reusable allocator through a conditional.

Zero free list.

Member Function Documentation

◆ next()

ReusableObject * ucommon::ReusableAllocator::next ( ReusableObject * object)
inlineprotected

Get next reusable object in the pool.

Parameters
objectfrom list.
Returns
next object.

Definition at line 435 of file thread.h.

Here is the call graph for this function:

◆ release()

void ucommon::ReusableAllocator::release ( ReusableObject * object)
protected

Release resuable object.

Parameters
objectbeing released.

Field Documentation

◆ freelist

ReusableObject* ucommon::ReusableAllocator::freelist
protected

Definition at line 422 of file thread.h.

◆ waiting

unsigned ucommon::ReusableAllocator::waiting
protected

Definition at line 423 of file thread.h.


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