29 #ifndef _UCOMMON_CONTAINERS_H_
30 #define _UCOMMON_CONTAINERS_H_
32 #ifndef _UCOMMON_CONFIG_H_
36 #ifndef _UCOMMON_PROTOCOLS_H_
40 #ifndef _UCOMMON_LINKED_H_
44 #ifndef _UCOMMON_MEMORY_H_
48 #ifndef _UCOMMON_THREAD_H_
78 operator bool()
const;
84 bool operator!()
const;
99 size_t bufsize, objsize;
100 caddr_t buf, head, tail;
101 unsigned objcount,
limit;
109 Buffer(
size_t typesize,
size_t count);
135 void put(
void *data);
158 void copy(
void *data);
175 void *peek(
unsigned item);
177 virtual void *invalid(
void)
const;
184 unsigned size(
void)
const;
190 unsigned count(
void)
const;
196 operator bool()
const;
202 bool operator!()
const;
299 size_t count(
void)
const;
384 size_t count(
void)
const;
405 for(
unsigned i = 0; i < size; ++i)
406 array[i].enlist(&freelist);
413 {
return static_cast<T *
>(LinkedAllocator::get());}
416 {
return static_cast<T *
>(LinkedAllocator::get(timeout));}
418 inline void release(T *node)
419 {LinkedAllocator::release(node);}
442 Buffer(sizeof(T), capacity) {}
450 {
return static_cast<T*
>(
get());}
458 {
return static_cast<T*
>(
get(timeout));}
465 inline void put(T *
object)
475 {
return put(
object, timeout);}
492 {
return copy(
object, timeout);}
500 inline const T&
at(
unsigned item)
512 inline T* operator()(
unsigned offset = 0)
541 inline bool remove(T *object)
572 {
return static_cast<const T *
>(Stack::peek(timeout));}
574 inline T* operator()(
unsigned offset = 0)
583 inline const T&
at(
unsigned offset = 0)
584 {
return static_cast<const T&
>(
Stack::get(offset));}
622 inline bool remove(T *object)
662 inline const T&
at(
unsigned offset = 0)
663 {
return static_cast<const T&
>(
Queue::get(offset));}
674 inline T* operator()(
unsigned offset = 0)
const T & at(unsigned offset=0)
Examine past item in the queue.
bool remove(ObjectProtocol *object)
Remove a specific object pointer for the queue.
Abstract interfaces and support.
A thread-safe buffer for serializing and streaming class data.
Stack stack_t
Convenience type for using thread-safe object stacks.
Manage a thread-safe stack of objects through reference pointers.
LinkedObject * get(void)
Get (pull) object off the list.
A common base class for all managed objects.
ObjectProtocol * pull(timeout_t timeout=0)
Get and remove last object pushed on the stack.
Linked objects, lists, templates, and containers.
unsigned long timeout_t
Typedef for millisecond timer values.
A managed private heap for small allocations.
bool remove(ObjectProtocol *object)
Remove a specific object pointer for the queue.
T * lifo(timeout_t timeout=0)
Get and remove last typed object posted to the queue.
bool post(ObjectProtocol *object, timeout_t timeout=0)
Post an object into the queue by it's pointer.
T &() limit(T &value, T &low, T &high)
Convenience macro to range restrict values.
Common namespace for all ucommon objects.
Mempager managed type factory for pager pool objects.
A linked object base class for ordered objects.
T * fifo(timeout_t timeout=0)
Get and remove first typed object posted to the queue.
T * pull(timeout_t timeout=0)
Get and remove last typed object posted to the stack.
Common base class for all objects that can be formed into a linked list.
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
T & operator[](unsigned offset)
Examine past item in the queue.
Various miscellaneous platform specific headers and defines.
bool push(T *object, timeout_t timeout=0)
Push a typed object into the stack by it's pointer.
const T & at(unsigned offset=0)
Examine past item in the stack.
Linked allocator template to gather linked objects.
bool push(ObjectProtocol *object, timeout_t timeout=0)
Push an object into the stack by it's pointer.
Thread classes and sychronization objects.
Private heaps, pools, and associations.
Queue fifo_t
Convenience type for using thread-safe object fifo (queue).
const T & at(unsigned item)
Examine past item in the buffer.
Manage a thread-safe queue of objects through reference pointers.
stackof(mempager *memory, size_t size=0)
Create templated stack of typed objects.
An index container for maintaining an ordered list of objects.
const T & operator[](unsigned offset)
Examine past item in the stack.
A templated typed class for buffering of objects.
void * peek(unsigned item)
Peek at pending data in buffer.
ObjectProtocol * lifo(timeout_t timeout=0)
Get and remove first object posted to the queue.
bool post(T *object, timeout_t timeout=0)
Post a typed object into the queue by it's pointer.
A templated typed class for thread-safe stack of object pointers.
bool put(T *object, timeout_t timeout)
Put (copy) an object into the buffer.
A templated typed class for thread-safe queue of object pointers.
ObjectProtocol * get(unsigned offset=0)
Examine an existing object on the stack.
bufferof(unsigned capacity)
Create a buffer to hold a series of typed objects.
void put(T *object)
Put (copy) a typed object into the buffer.
queueof(mempager *memory, size_t size=0)
Create templated queue of typed objects.
void copy(T *object)
Copy the next typed object from the buffer.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
ObjectProtocol * fifo(timeout_t timeout=0)
Get and remove last object posted to the queue.
Linked allocator helper for linked_allocator template.
T & operator[](unsigned item)
Examine past item in the buffer.
const T * peek(timeout_t timeout=0)
Examine last typed object posted to the stack.
The conditional is a common base for other thread synchronizing classes.