![]() |
VR-Exchange 2.2 API Documentation
|
Implements a message queue for multiple subscribers. More...

Classes | |
| struct | DtBucketHeader |
| DtBucketHeader is a structure found at the front of each message to keep track of the number of bytes used. More... | |
| struct | DtQueueHeader |
| DtQueueHeader exists at the front of the message queue and contains useful information about the state of the queue. More... | |
Public Member Functions | |
| DtSubscribableMessageQueue (const DtString &name, DtU8 subscriberId) | |
| Creates an instance of a Shared Memory Queue with the given name IMPORTANT: memory with the given name must have already been allocated somewhere, This class will only attach to it. | |
| virtual | ~DtSubscribableMessageQueue () |
| virtual bool | isEmpty () |
| Returns true if the queue has messages no messages in it. | |
| virtual bool | isSubscribed (DtU8 subscriberId) const |
| Test if subscriberId is subscribed. | |
| virtual DtU32 | subscriberDrops (DtU8 subscriberId) const |
| Returns the number of dropped messages for subscriberId, will return 0 if not subscribed. | |
| virtual void | sendMessage (const void *message, unsigned int size) |
| Sends a packet at address message of size bytes to the queue. | |
| virtual void * | message (unsigned int *outSize=0) |
| Returns a copy of the message which must be freed by the caller or returns null if there are not messages to read. | |
| virtual void | unsubscribe (DtU8 id) |
| Unsubscribes subscriber id from the queue. | |
| void | subscribe (DtU8 id) |
| Subscribes subscriber id from the queue. | |
| virtual void | resetQueue (DtU32 numberOfBuckets, DtU32 payloadSize) |
| Empties the queue. | |
| virtual void | initLocks () |
| Initializes Shared Memory locks. | |
| virtual void | clearLocks () |
| This clears all locks and should only be called by the queue manager. | |
| virtual std::ostream & | printDataToStream (std::ostream &str) const |
| prints the state of the queue to the given stream | |
| virtual DtString | name () const |
| returns the name of the queue. | |
| DtQueueHeader * | queueHeader () const |
| returns a pointer to the queue header, called from CTOR | |
| DtU32 | numberOfBuckets () const |
| Returns the number of buckets in this queue. | |
| DtU32 | payloadSize () const |
| Returns the number of bytes used in a bucket payload. | |
| virtual char * | payloadInBucket (unsigned int bucketNum) const |
| returns a pointer to the payload in the bucket. | |
| virtual DtBucketHeader * | bucketHeader (unsigned int bucketNum) const |
| returns a pointer to the message header at index | |
Static Public Member Functions | |
| static unsigned int | poolSize (DtU32 numberOfBuckets, DtU32 payloadSize) |
| Used to compute the size in bytes, required for a DtSmSubscribableMessageQueue instance using numberOfBuckets with a payload size of payloadSize. | |
Static Public Attributes | |
| static const unsigned int | theMaxSubscribers = 255 |
| The maximum number of subscribers allowed in this queue. | |
Protected Member Functions | |
| virtual void | lockForRead () |
| Locks the queue for a read. | |
| virtual void | unlockForRead () |
| Unlocks the queue for a read. | |
| virtual void | lockForWrite () |
| Locks the queue for a write. | |
| virtual void | unlockForWrite () |
| Unlocks the queue for writes. | |
Protected Attributes | |
| DtSharedMemoryPoolClient * | myShmPool |
| DtString | myShmName |
| DtU8 | mySubscriberId |
| std::vector< char > | myReadBuffer |
Private Member Functions | |
| DtSubscribableMessageQueue (const DtSubscribableMessageQueue &other) | |
| Copy Ctor Not implemented – Class Not Copyable. | |
| DtSubscribableMessageQueue & | operator= (const DtSubscribableMessageQueue &other) |
| Assignment Operator Not implemented – Class Not Copyable. | |
Implements a message queue for multiple subscribers.
This is a fixed length queue, of fixed length messages. It is implemented as a circular list and will not fill up, but rather overwrite the oldest unread messages. Subscribers are given a 8 bit id and register their interest in messages merely by creating an instance of this class. A subscriber can unsubscribe at any time. Before an instance of this class can be created there must already be a shared memory pool of the correct size open. The correct size is computed using DtSubscribableMessageQueue::poolSize(). Before a queue can be used one subscriber (and only one subscriber) must call queue->reset(...); queue->initlocks();
| MAKVrExchange::DtSubscribableMessageQueue::DtSubscribableMessageQueue | ( | const DtString & | name, |
| DtU8 | subscriberId | ||
| ) |
Creates an instance of a Shared Memory Queue with the given name IMPORTANT: memory with the given name must have already been allocated somewhere, This class will only attach to it.
The memory must be at least as big as ::poolSize(), this queue can't check.
|
virtual |
|
private |
Copy Ctor Not implemented – Class Not Copyable.
|
private |
Assignment Operator Not implemented – Class Not Copyable.
|
virtual |
Returns true if the queue has messages no messages in it.
Implements MAKVrExchange::DtMessageQueue.
|
virtual |
Test if subscriberId is subscribed.
|
virtual |
Returns the number of dropped messages for subscriberId, will return 0 if not subscribed.
|
virtual |
Sends a packet at address message of size bytes to the queue.
If the queue is full this message will knock the oldest message off the queue.
Implements MAKVrExchange::DtMessageQueue.
|
virtual |
Returns a copy of the message which must be freed by the caller or returns null if there are not messages to read.
If outsize is passed then the size of the message is returned.
Implements MAKVrExchange::DtMessageQueue.
|
virtual |
Unsubscribes subscriber id from the queue.
This is called by the DTOR and should not be called by users of this class. It is public however, so that some classes which are managing the queue, can force unsubscribe someone who is misbehaving. USE with CAUTION
| void MAKVrExchange::DtSubscribableMessageQueue::subscribe | ( | DtU8 | id | ) |
Subscribes subscriber id from the queue.
This is called by the DTOR and should not be called by users of this class. It is public however, so that some classes which are managing the queue, can force subscribe someone. USE with CAUTION
|
virtual |
Empties the queue.
This should only be called by the queue manager, as all unread messages are lost and all subscribers are unsubscribed.
|
virtual |
Initializes Shared Memory locks.
one party, the queue manager.
|
virtual |
This clears all locks and should only be called by the queue manager.
|
virtual |
prints the state of the queue to the given stream
Implements MAKVrExchange::DtMessageQueue.
|
static |
Used to compute the size in bytes, required for a DtSmSubscribableMessageQueue instance using numberOfBuckets with a payload size of payloadSize.
Each bucket is the size of the payload + the size of a bucketHeader
|
virtual |
returns the name of the queue.
| DtQueueHeader* MAKVrExchange::DtSubscribableMessageQueue::queueHeader | ( | ) | const |
returns a pointer to the queue header, called from CTOR
| DtU32 MAKVrExchange::DtSubscribableMessageQueue::numberOfBuckets | ( | ) | const |
Returns the number of buckets in this queue.
| DtU32 MAKVrExchange::DtSubscribableMessageQueue::payloadSize | ( | ) | const |
Returns the number of bytes used in a bucket payload.
|
virtual |
returns a pointer to the payload in the bucket.
Where a bucket is composed of the bucketHeader and the bucketPayload
|
virtual |
returns a pointer to the message header at index
|
protectedvirtual |
Locks the queue for a read.
|
protectedvirtual |
Unlocks the queue for a read.
|
protectedvirtual |
Locks the queue for a write.
|
protectedvirtual |
Unlocks the queue for writes.
|
static |
The maximum number of subscribers allowed in this queue.
|
protected |
|
protected |
|
protected |
|
protected |