30 #ifndef _UCOMMON_CONTAINERS_H_
31 #define _UCOMMON_CONTAINERS_H_
33 #ifndef _UCOMMON_CONFIG_H_
37 #ifndef _UCOMMON_PROTOCOLS_H_
41 #ifndef _UCOMMON_LINKED_H_
45 #ifndef _UCOMMON_MEMORY_H_
49 #ifndef _UCOMMON_THREAD_H_
79 operator bool()
const;
85 bool operator!()
const;
100 size_t bufsize, objsize;
101 caddr_t buf, head, tail;
102 unsigned objcount,
limit;
110 Buffer(
size_t typesize,
size_t count);
122 void *
get(timeout_t timeout);
136 void put(
void *data);
144 bool put(
void *data, timeout_t timeout);
159 void copy(
void *data);
167 bool copy(
void *data, timeout_t timeout);
176 void *peek(
unsigned item);
178 virtual void *invalid(
void)
const;
185 unsigned size(
void)
const;
191 unsigned count(
void)
const;
197 operator bool()
const;
203 bool operator!()
const;
300 size_t count(
void)
const;
385 size_t count(
void)
const;
406 for(
unsigned i = 0; i < size; ++i)
407 array[i].enlist(&freelist);
414 inline T *
get(void) {
415 return polypointer_cast<T *>(LinkedAllocator::get());
418 inline T *
get(timeout_t timeout) {
419 return polypointer_cast<T *>(LinkedAllocator::get(timeout));
422 inline void release(T *node) {
423 LinkedAllocator::release(node);
447 Buffer(sizeof(T), capacity) {}
454 inline T *
get(void) {
455 return static_cast<T*
>(
get());
463 inline T *
get(timeout_t timeout) {
464 return static_cast<T*
>(
get(timeout));
472 inline void put(T *
object) {
482 inline bool put(T *
object, timeout_t timeout) {
483 return put(
object, timeout);
501 inline bool get(T *object, timeout_t timeout) {
502 return copy(
object, timeout);
511 inline const T&
at(
unsigned item) {
525 inline T* operator()(
unsigned offset = 0) {
555 inline bool remove(T *object) {
556 return Stack::remove(polypointer_cast<ObjectProtocol*>(
object));
567 inline bool push(T *
object, timeout_t timeout = 0) {
568 return Stack::push(polypointer_cast<ObjectProtocol*>(
object), timeout);
578 inline T *
pull(timeout_t timeout = 0) {
579 return polypointer_cast<T *>(
Stack::pull(timeout));
588 inline const T *
peek(timeout_t timeout = 0) {
589 return polypointer_cast<
const T *>(Stack::peek(timeout));
592 inline T* operator()(
unsigned offset = 0) {
593 return polypointer_cast<T*>(
Stack::get(offset));
602 inline const T&
at(
unsigned offset = 0) {
603 return polyreference_cast<
const T&>(
Stack::get(offset));
613 return polyreference_cast<T&>(
Stack::get(offset));
643 inline bool remove(T *object) {
644 return Queue::remove(polypointer_cast<ObjectProtocol *>(
object));
655 inline bool post(T *
object, timeout_t timeout = 0) {
656 return Queue::post(polypointer_cast<ObjectProtocol*>(
object), timeout);
666 inline T *
fifo(timeout_t timeout = 0) {
667 return polypointer_cast<T *>(
Queue::fifo(timeout));
677 inline T *
lifo(timeout_t timeout = 0) {
678 return polypointer_cast<T *>(
Queue::lifo(timeout));
687 inline const T&
at(
unsigned offset = 0) {
688 return polyreference_cast<
const T&>(
Queue::get(offset));
698 return polyreference_cast<T&>(
Queue::get(offset));
701 inline T* operator()(
unsigned offset = 0) {
702 return polypointer_cast<T*>(
Queue::get(offset));
The conditional is a common base for other thread synchronizing classes.
bool push(ObjectProtocol *object, timeout_t timeout=0)
Push an object into the stack by it's pointer.
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
Linked allocator template to gather linked objects.
Thread classes and sychronization objects.
Various miscellaneous platform specific headers and defines.
A thread-safe buffer for serializing and streaming class data.
Queue fifo_t
Convenience type for using thread-safe object fifo (queue).
queueof(mempager *memory, size_t size=0)
Create templated queue of typed objects.
const T & at(unsigned offset=0)
Examine past item in the queue.
const T & at(unsigned offset=0)
Examine past item in the stack.
A managed private heap for small allocations.
Common base class for all objects that can be formed into a linked list.
A linked object base class for ordered objects.
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.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
bool push(T *object, timeout_t timeout=0)
Push a typed object into the stack by it's pointer.
A templated typed class for thread-safe stack of object pointers.
Linked objects, lists, templates, and containers.
void copy(T *object)
Copy the next typed object from the buffer.
Private heaps, pools, and associations.
A common base class for all managed objects.
LinkedObject * get(void)
Get (pull) object off the list.
An index container for maintaining an ordered list of objects.
stackof(mempager *memory, size_t size=0)
Create templated stack of typed objects.
ObjectProtocol * lifo(timeout_t timeout=0)
Get and remove first object posted to the queue.
ObjectProtocol * fifo(timeout_t timeout=0)
Get and remove last object posted to the queue.
bool put(T *object, timeout_t timeout)
Put (copy) an object into the buffer.
T * lifo(timeout_t timeout=0)
Get and remove last typed object posted to the queue.
T &() limit(T &value, T &low, T &high)
Convenience macro to range restrict values.
Common namespace for all ucommon objects.
T * pull(timeout_t timeout=0)
Get and remove last typed object posted to the stack.
Manage a thread-safe stack of objects through reference pointers.
bool remove(ObjectProtocol *object)
Remove a specific object pointer for the queue.
const T & at(unsigned item)
Examine past item in the buffer.
Mempager managed type factory for pager pool objects.
ObjectProtocol * get(unsigned offset=0)
Examine an existing object on the stack.
bool remove(ObjectProtocol *object)
Remove a specific object pointer for the queue.
ObjectProtocol * pull(timeout_t timeout=0)
Get and remove last object pushed on the stack.
A templated typed class for thread-safe queue of object pointers.
Linked allocator helper for linked_allocator template.
T & operator[](unsigned offset)
Examine past item in the queue.
void * peek(unsigned item)
Peek at pending data in buffer.
bool post(ObjectProtocol *object, timeout_t timeout=0)
Post an object into the queue by it's pointer.
Abstract interfaces and support.
A templated typed class for buffering of objects.
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.
bool post(T *object, timeout_t timeout=0)
Post a typed object into the queue by it's pointer.
const T & operator[](unsigned offset)
Examine past item in the stack.
Stack stack_t
Convenience type for using thread-safe object stacks.
T * fifo(timeout_t timeout=0)
Get and remove first typed object posted to the queue.
Manage a thread-safe queue of objects through reference pointers.