Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
#include <SharedQueue.h>
Inheritance diagram for SharedQueue< maxsize, maxentries >:
This doesn't gain you much functionality over the Aperios messages - in fact, you lose some because you have to poll this for new data whereas Aperios will notify you.
However, the big advantage of this is that you don't have any lag time from the system in sending the message from one process to the other - it's instantly available. Also, you can poll for new data from within a loop, whereas you cannot check to see if you have any messages waiting from Aperios until you exit to the system.
This makes no assumptions about the data to be stored - it's all just an array of bytes
Assumptions are made about reception usage: all entries will be processed and then cleared so that the queue is emptied. You cannot pop the front, only clear the whole thing. This assumption allows much simpler/faster access. (Otherwise we need to implement a circular buffer and worry about wrap around. *shrug* Not too hard, but unnecessary complication for now.)
Definition at line 27 of file SharedQueue.h.
Public Member Functions | |
SharedQueue () | |
constructor | |
template<class T> bool | SharedQueue (const T &obj) |
inserts a class into the queue | |
void * | reserve (unsigned int size) |
reserves a number of bytes in the queue, LEAVES QUEUE LOCKED, call done when finished | |
void | done () |
call this when you're finished filling in a buffer you received from reserve | |
bool | clear (unsigned int taken) |
checks to see if the number taken by the reader is the number added, and then clears | |
unsigned int | size () const |
returns current number of entries | |
unsigned int | size (unsigned int i) const |
returns size of entry i | |
const void * | data (unsigned int i) const |
returns data of entry i | |
Static Public Attributes | |
const unsigned int | MAX_SIZE = maxsize |
maximum capacity of data storage for the queue | |
const unsigned int | MAX_ENTRIES = maxentries |
maximum number of entries that can be queued | |
Protected Types | |
typedef LockScope< ProcessID::NumProcesses > | AutoLock |
for convenience in locking functions | |
Protected Member Functions | |
unsigned int | buf_end () |
returns the first free byte in buf | |
unsigned int | round_up (unsigned int sz) |
returns sz rounded up to the nearest word (makes sz divisible by sizeof(int)) | |
Protected Attributes | |
MutexLock< ProcessID::NumProcesses > | lock |
provides mutual exclusion on non-const functions | |
char | buf [MAX_SIZE] |
data storage | |
unsigned int | len |
holds number of entries | |
entry_t | entries [MAX_ENTRIES] |
holds entry information |
|
for convenience in locking functions
Definition at line 71 of file SharedQueue.h. Referenced by SharedQueue< maxsize, maxentries >::clear(), and SharedQueue< maxsize, maxentries >::reserve(). |
|
constructor
Definition at line 90 of file SharedQueue.h. |
|
inserts a class into the queue
|
|
returns the first free byte in buf
Definition at line 63 of file SharedQueue.h. Referenced by SharedQueue< maxsize, maxentries >::reserve(). |
|
checks to see if the number taken by the reader is the number added, and then clears This will allow you to process entries without locking the entire queue, but still not worry about missing one (or more) if it was added while you were processing the last one. Definition at line 124 of file SharedQueue.h. Referenced by EventTranslator::translateEvents(). |
|
returns data of entry i
Definition at line 59 of file SharedQueue.h. Referenced by EventTranslator::translateEvents(). |
|
call this when you're finished filling in a buffer you received from reserve
Definition at line 44 of file SharedQueue.h. Referenced by EventTranslator::enqueue(). |
|
reserves a number of bytes in the queue, LEAVES QUEUE LOCKED, call done when finished
Definition at line 111 of file SharedQueue.h. Referenced by EventTranslator::enqueue(). |
|
returns sz rounded up to the nearest word (makes sz divisible by sizeof(int))
Definition at line 66 of file SharedQueue.h. Referenced by SharedQueue< maxsize, maxentries >::reserve(). |
|
returns size of entry i
Definition at line 56 of file SharedQueue.h. |
|
returns current number of entries
Definition at line 53 of file SharedQueue.h. Referenced by SharedQueue< maxsize, maxentries >::clear(), and EventTranslator::translateEvents(). |
|
data storage
Definition at line 74 of file SharedQueue.h. Referenced by SharedQueue< 3 *1024, 100 >::data(), and SharedQueue< maxsize, maxentries >::reserve(). |
|
holds entry information
Definition at line 86 of file SharedQueue.h. Referenced by SharedQueue< 3 *1024, 100 >::buf_end(), SharedQueue< 3 *1024, 100 >::data(), SharedQueue< maxsize, maxentries >::reserve(), and SharedQueue< 3 *1024, 100 >::size(). |
|
holds number of entries
Definition at line 83 of file SharedQueue.h. Referenced by SharedQueue< 3 *1024, 100 >::buf_end(), SharedQueue< maxsize, maxentries >::clear(), SharedQueue< maxsize, maxentries >::reserve(), and SharedQueue< 3 *1024, 100 >::size(). |
|
provides mutual exclusion on non-const functions
Definition at line 69 of file SharedQueue.h. Referenced by SharedQueue< maxsize, maxentries >::clear(), SharedQueue< 3 *1024, 100 >::done(), and SharedQueue< maxsize, maxentries >::reserve(). |
|
maximum number of entries that can be queued
Definition at line 32 of file SharedQueue.h. Referenced by SharedQueue< maxsize, maxentries >::reserve(). |
|
maximum capacity of data storage for the queue
Definition at line 30 of file SharedQueue.h. Referenced by SharedQueue< maxsize, maxentries >::reserve(). |
Tekkotsu v2.0 |
Generated Wed Jan 21 03:23:26 2004 by Doxygen 1.3.4 |