Go to the documentation of this file.
44 #ifndef CCXX_BUFFER_H_
45 #define CCXX_BUFFER_H_
47 #ifndef CCXX_THREAD_H_
50 #ifndef CCXX_STRING_H_
53 #ifdef CCXX_NAMESPACES
97 virtual size_t onPeek(
void *buf) = 0;
193 char *buf, *head, *tail;
283 virtual void final();
345 void post(
const void *data,
unsigned len);
351 {
return b.
wait(o, t);}
355 {
return b.
post(o, t);}
362 #ifdef CCXX_NAMESPACES
A buffer class that holds a known capacity of fixed sized objects defined during creation.
Definition: buffer.h:191
virtual void startQueue(void)
Start of dequeing.
struct _data * next
Definition: buffer.h:268
size_t peek(Buffer &b, void *o)
Definition: buffer.h:358
Every thread of execution in an application is created by instantiating an object of a class derived ...
Definition: thread.h:1094
FixedBuffer(size_t capacity, size_t objsize)
Create a buffer of known capacity for objects of a specified size.
ThreadQueue(const char *id, int pri, size_t stack=0)
Create instance of our queue and give it a process priority.
virtual ~Buffer()
In derived functions, may be used to free the actual memory used to hold buffered data.
timeout_t timeout
Definition: buffer.h:273
unsigned long timeout_t
Definition: thread.h:74
Common C++ generic string class.
size_t onPost(void *buf)
Post an object of the appropriate size into the buffer.
int HANDLE
Definition: serial.h:60
size_t onWait(void *buf)
Wait for and return a fixed object in the buffer.
The Mutex class is used to protect a section of code so that at any given time only a single thread c...
Definition: thread.h:187
size_t wait(void *buf, timeout_t timeout=0)
Let one or more threads wait for an object to become available in the buffer.
size_t get(Buffer &b, void *o, timeout_t t=0)
Definition: buffer.h:350
virtual ~ThreadQueue()
Destroy the queue.
A conditional variable synchcronization object for one to one and one to many signal and control even...
Definition: thread.h:637
virtual ~FixedBuffer()
Destroy the fixed buffer and free the memory used to store objects.
virtual size_t onWait(void *buf)=0
Invoke derived class object request from buffer.
Somewhat generic queue processing class to establish a producer consumer queue.
Definition: buffer.h:262
size_t getSize(void)
Return the capacity of the buffer as specified at creation.
Definition: buffer.h:135
virtual size_t onPeek(void *buf)=0
Invoke derived class buffer peeking method.
size_t peek(void *buf)
Peek at the current content (first object) in the buffer.
size_t onPeek(void *buf)
Return the first object in the buffer.
#define __EXPORT
Definition: config.h:979
bool started
Definition: buffer.h:274
virtual void stopQueue(void)
End of dequeing, we expect the queue is empty for now.
unsigned len
Definition: buffer.h:269
A semaphore is generally used as a synchronization object between multiple threads or to protect a li...
Definition: thread.h:734
The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be ...
Definition: buffer.h:83
size_t post(void *buf, timeout_t timeout=0)
Post an object into the buffer and enable a waiting thread to receive it.
void post(const void *data, unsigned len)
Put some unspecified data into this queue.
void setTimer(timeout_t timeout)
Set the queue timeout.
String name
Definition: buffer.h:278
size_t put(Buffer &b, void *o, timeout_t t=0)
Definition: buffer.h:354
static const size_t timeout
value to return when a timed operation returned with a timeout.
Definition: buffer.h:118
FixedBuffer(const FixedBuffer &fb)
Create a copy of an existing fixed size buffer and duplicate it's contents.
virtual size_t onPost(void *buf)=0
Invoke derived class posting of object to buffer.
virtual void runQueue(void *data)=0
Virtual callback method to handle processing of a queued data items.
virtual bool isValid(void)
New virtual to test if buffer is a valid object.
virtual void onTimer(void)
A derivable method to call when the timout is expired.
data_t * last
Definition: buffer.h:276
size_t getUsed(void)
Return the current capacity in use for the buffer.
Definition: buffer.h:144
Synchronization and threading services.
FixedBuffer & operator=(const FixedBuffer &fb)
This is a generic and portable string class.
Definition: string.h:81
Buffer(size_t capacity)
Create a buffer object of known capacity.