![]() |
WebLVC 1.8 API Documentation
|
Implements a message queue for multiple subscribers. 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. More... | |
| virtual | ~DtSubscribableMessageQueue () |
| Virtual DTOR. More... | |
| virtual bool | isEmpty () |
| Returns true if the queue has messages no messages in it. More... | |
| virtual bool | isSubscribed (DtU8 subscriberId) const |
| Test if subscriberId is subscribed. More... | |
| virtual DtU32 | subscriberDrops (DtU8 subscriberId) const |
| Returns the number of dropped messages for subscriberId, will return 0 if not subscribed. More... | |
| virtual void | sendMessage (const void *message, unsigned int size, bool global=false) |
| Sends a packet at address message of size bytes to the queue. More... | |
| 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. More... | |
| virtual void | unsubscribe (DtU8 id) |
| Unsubscribes subscriber id from the queue. More... | |
| void | subscribe (DtU8 id) |
| Subscribes subscriber id from the queue. More... | |
| virtual void | resetQueue (DtU32 numberOfBuckets, DtU32 payloadSize) |
| Empties the queue. More... | |
| virtual std::ostream & | printDataToStream (std::ostream &str) const |
| prints the state of the queue to the given stream More... | |
| virtual DtString | name () const |
| returns the name of the queue. More... | |
| DtQueueHeader * | queueHeader () const |
| returns a pointer to the queue header, called from CTOR More... | |
| DtU32 | numberOfBuckets () const |
| Returns the number of buckets in this queue. More... | |
| DtU32 | payloadSize () const |
| Returns the number of bytes used in a bucket payload. More... | |
| virtual char * | payloadInBucket (unsigned int bucketNum) const |
| returns a pointer to the payload in the bucket. More... | |
| virtual DtBucketHeader * | bucketHeader (unsigned int bucketNum) const |
| returns a pointer to the message header at index More... | |
| virtual int | usedBucketCount () const |
| Computes the number of used buckets and returns it. More... | |
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. More... | |
Static Public Attributes | |
| static const unsigned int | theMaxSubscribers = 256 |
| The maximum number of subscribers allowed in this queue. More... | |
| static unsigned long | theLockFailureTimeoutMs |
| The timeout for lock attempts (in seconds). More... | |
Protected Attributes | |
| std::vector< char > | myReadBuffer |
| DtU8 | mySubscriberId |
| DtString | myShmName |
| DtSharedMemoryPoolClient * | myShmPool |
Private Member Functions | |
| DtSubscribableMessageQueue (const DtSubscribableMessageQueue &other) | |
| Copy Ctor Not implemented – Class Not Copyable. More... | |
| DtSubscribableMessageQueue & | operator= (const DtSubscribableMessageQueue &other) |
| Assignment Operator Not implemented – Class Not Copyable. More... | |
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. Also: Subscriber ID is the id used to reference this queue when reading and writing messages to/from the queue. The following IDs are reserved: ID 0: Reserved for identifying globally sent messages. ID 1: Reserved for the queue manager. ID 4: Reserved for messageDump.
|
virtual |
Virtual DTOR.
|
private |
Copy Ctor Not implemented – Class Not Copyable.
|
virtual |
returns a pointer to the message header at index
|
virtual |
Returns true if the queue has messages no messages in it.
Implements MAKVrExchange::DtMessageQueue.
|
virtual |
Test if subscriberId is subscribed.
|
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 |
returns the name of the queue.
| DtU32 MAKVrExchange::DtSubscribableMessageQueue::numberOfBuckets | ( | ) | const |
Returns the number of buckets in this queue.
|
private |
Assignment Operator Not implemented – Class Not Copyable.
|
virtual |
returns a pointer to the payload in the bucket.
Where a bucket is composed of the bucketHeader and the bucketPayload
| DtU32 MAKVrExchange::DtSubscribableMessageQueue::payloadSize | ( | ) | const |
Returns the number of bytes used in a bucket payload.
|
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 |
prints the state of the queue to the given stream
Implements MAKVrExchange::DtMessageQueue.
| DtQueueHeader* MAKVrExchange::DtSubscribableMessageQueue::queueHeader | ( | ) | const |
returns a pointer to the queue header, called from CTOR
|
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 |
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. The global parameter indicates whether this message should be sent 'globally' - this is primarily used for sending message which can be discovered by all subscribers.
Implements MAKVrExchange::DtMessageQueue.
| 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 |
Returns the number of dropped messages for subscriberId, will return 0 if not subscribed.
|
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
|
virtual |
Computes the number of used buckets and returns it.
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
The timeout for lock attempts (in seconds).
If lock is not successful after this amount of time, the lock is retried.
|
static |
The maximum number of subscribers allowed in this queue.