MAK RTIspy API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vlShmSubscribableMessageQueue__rti__.h
Go to the documentation of this file.
1 /*********************************************************************
2  ** Copyright (c) 2005 MaK Technologies, Inc.
3  ** All rights reserved.
4  *********************************************************************/
5 /*********************************************************************
6  ** $RCSfile: vlShmSubscribableMessageQueue__rti__.h,v $ $Revision: 1.3 $ $State: Exp $
7  *********************************************************************/
8 #ifndef vlShmSubscribableMessageQueue__rti___H_
9 #define vlShmSubscribableMessageQueue__rti___H_
10 
14 
15 #include "rtiMsConfig.h"
17 #include "vlShmPool__rti__.h"
18 #include <vlutil/vlTime.h>
19 #include "vlIpcRdWrLock__rti__.h"
20 #include "vlIpcMutex__rti__.h"
21 #include <vlutil/vlNetTypes.h>
22 #include <vector>
23 #include <limits.h>
24 
25 #ifndef WIN32
26 #include <pthread.h>
27 #endif
28 
29 #ifdef DtUSE_UTILITIES_NAMESPACE
30 namespace DtUSE_UTILITIES_NAMESPACE
31 {
32 #endif
33 
34 #define DtSm_QUEUE_STATE_UNINITIALIZED 0x0
35 #define DtSm_QUEUE_STATE_INITIALIZED 0xFAD2FADE
36 #define DtSm_QUEUE_STATE_SHUTDOWN 0xDEADBEEF
37 #define DtSM_INVALID_SUBSCRIBER_ID UINT_MAX
38 
41 #define DtSMQ_FETCH_DEFAULT 0x00
42 #define DtSMQ_SKIP_MINE 0x40
43 #define DtSMQ_FETCH_ALL 0x80
44 
45 #define DtSmSubMsgQ_theMaxSubscribers 255
51 
53 //
67 {
68 
69 public:
70 
75  DtSmSubscribableMessageQueue__rti__(const MAKRti::DtString &name);
77 
78 private:
79 
82 
85 
86 public:
87 
90  virtual int subscribe(MAKRti::DtU32 subscriberId = DtSM_INVALID_SUBSCRIBER_ID);
91 
101  virtual void unsubscribe(MAKRti::DtU32 id);
102 
104  virtual bool isSubscribed(MAKRti::DtU32 subscriberId) const;
105 
107  virtual MAKRti::DtU32 subscriberId() const;
108 
110  virtual int subscriberCount() const;
111 
118  virtual bool isEmpty();
119  virtual bool isEmpty(int *nextSize, MAKRti::DtU32 flagsMask = DtSMQ_FETCH_DEFAULT);
120 
123  //
124  virtual void setDefaultReadBehavior(MAKRti::DtU32 flagsMask);
125 
130  virtual bool sendMessage(const void *message, unsigned int size);
131 
137  virtual void* message(unsigned int *outSize = 0);
138  virtual void* message(void *recvBuffer, unsigned int *outSize);
139 
141  //
144  virtual void resetQueue(MAKRti::DtU32 numberOfBuckets, MAKRti::DtU32 payloadSize);
145 
147  virtual bool sm_shutdown( bool ruthless = false );
148 
150  virtual volatile MAKRti::DtU32 queueState() const;
151 
153  //
156  virtual void initSyncVars();
157 
160  virtual void clearSyncVars();
161 
163  virtual std::ostream &printDataToStream(std::ostream &str) const;
164 
165 public:
166 
169  //
171  static unsigned int poolSize(MAKRti::DtU32 numberOfBuckets, MAKRti::DtU32 payloadSize);
172 
173 protected:
174 
177  struct DtQueueHeader;
178  struct DtBucketHeader;
179 
181  virtual int assignSubscriberId();
182 
184  virtual unsigned int maxSubscribers() const;
185 
187  volatile DtQueueHeader *queueHeader() const;
188 
190  virtual MAKRti::DtU32 queueHeaderSize() const;
191 
193  virtual MAKRti::DtU32 numberOfBuckets() const;
194 
196  virtual MAKRti::DtU32 payloadSize() const;
197 
200  virtual volatile MAKRti::DtU32 queueFront(unsigned int sub) const;
201 
203  virtual volatile MAKRti::DtU32 queueBack() const;
204 
207  virtual volatile MAKRti::DtU32 queueBackstop() const;
208 
211  virtual MAKRti::DtU32 updateFront(unsigned int sub, unsigned int val);
212 
215  virtual MAKRti::DtU32 updateBack(unsigned int val);
216 
219  virtual MAKRti::DtU32 updateBackstop(unsigned int val);
220 
222  virtual void setSubscribed(unsigned int sub, unsigned int val);
223 
225  virtual int setSubscriberCount(MAKRti::DtU32 val);
226 
228  virtual int incrementSubscriberCount();
229 
231  virtual int decrementSubscriberCount();
232 
234  virtual void setState(MAKRti::DtU32 val);
235 
238  virtual volatile char* payloadInBucket(unsigned int bucketNum) const;
239 
241  virtual volatile void * bucketHeader(unsigned int bucketNum) const;
242 
244  virtual MAKRti::DtU32 bucketHeaderSize() const;
245 
247  virtual MAKRti::DtU32 bucketSenderId(unsigned int bucketNum) const;
248  virtual MAKRti::DtU32 bucketMsgSn(unsigned int bucketNum) const;
249  virtual MAKRti::DtU32 bucketOutstandingReadCount(unsigned int bucketNum) const;
250  virtual MAKRti::DtU32 bucketPayloadLen(unsigned int bucketNum) const;
251  virtual bool bucketIsFirst(unsigned int bucketNum) const;
252  virtual bool bucketIsLast(unsigned int bucketNum) const;
253 
255  virtual void setSenderId(unsigned int bucketNum, MAKRti::DtU32 sid);
256  virtual void setMsgSn(unsigned int bucketNum, MAKRti::DtU32 seqnum);
257  virtual void setOutstandingReadCount(unsigned int bucketNum, MAKRti::DtU32 val);
258  virtual void decrementOutstandingReadCount(unsigned int bucketNum);
259  virtual void setPayloadLen(unsigned int bucketNum, MAKRti::DtU32 len);
260  virtual void setFirst(unsigned int bucketNum, MAKRti::DtU32 val);
261  virtual void setLast(unsigned int bucketNum, MAKRti::DtU32 val);
262 
264  virtual void lockForRead();
266  virtual void unlockForRead();
267 
269  virtual void lockForWrite();
270 
272  virtual void unlockForWrite();
273 
276  virtual bool stalledSubscribers(unsigned int bucketNum,
277  unsigned int numStalled);
278 
281  virtual bool checkForStalls();
282 
283 #ifndef WIN32
284  virtual pthread_rwlock_t * rdWrLock();
288  virtual pthread_mutex_t * orcMutex();
289 #endif
290 
291 protected:
292 
294  MAKRti::DtString myShmName;
295  MAKRti::DtU32 mySubscriberId;
296  MAKRti::DtU32 myMessagesSentCnt;
299  std::vector<char> myReadBuffer;
300  MAKRti::DtU32 myDefaultReadMask;
301 
302 //TO DO -- DAA workaround for MSVC6 bug ID #241569
303 //A bug in MSVC++6 prevents initializing a static const member within a class
304 //declaration. It must be initialized outside the class. The bug is fixed
305 //in MSVC7, so when support for MSVC6 is dropped we can do away with this
306 //kludgy workaround
307 //static const unsigned int theMaxSubscribers = 255;
309  unsigned int theMaxSubscribers;
310 
311 protected:
312 
322  {
323  MAKRti::DtU32 senderId;
324  MAKRti::DtU32 msgSn;
325  MAKRti::DtU32 outstandingReadCount;
326  MAKRti::DtU32 sizeInBytes : 24;
327  MAKRti::DtU32 reserved_1 : 6;
328  MAKRti::DtU32 last : 1;
329  MAKRti::DtU32 first : 1;
330  };
331 
340  {
341  MAKRti::DtU32 state;
342  MAKRti::DtU32 payloadSize;
343  MAKRti::DtU32 numberOfBuckets;
344  MAKRti::DtU32 numberOfSubscribers;
345  MAKRti::DtU32 front[DtSmSubMsgQ_theMaxSubscribers];
346  MAKRti::DtU32 subscribed[DtSmSubMsgQ_theMaxSubscribers];
347  MAKRti::DtU32 back;
348  MAKRti::DtU32 backstop;
349 #ifndef WIN32
350  pthread_rwlock_t rwlock;
353  pthread_mutex_t ptOrcMutex;
354 #endif
355  };
356 };
357 
358 #ifdef DtUSE_UTILITIES_NAMESPACE
359 }
360 #endif
361 
362 #endif
363 
364 
MAKRti::DtU32 backstop
Definition: vlShmSubscribableMessageQueue__rti__.h:348
MAKRti::DtU32 payloadSize
Definition: vlShmSubscribableMessageQueue__rti__.h:342
#define DtSMQ_FETCH_DEFAULT
The following constants are intended as bit-masks to be combined with other values (some as-yet-unspe...
Definition: vlShmSubscribableMessageQueue__rti__.h:41
Implements a generic shared memory message queue for multiple subscribers.
Definition: vlShmSubscribableMessageQueue__rti__.h:66
MAKRti::DtU32 numberOfSubscribers
Definition: vlShmSubscribableMessageQueue__rti__.h:344
MAKRti::DtString myShmName
Definition: vlShmSubscribableMessageQueue__rti__.h:294
MAKRti::DtU32 mySubscriberId
Definition: vlShmSubscribableMessageQueue__rti__.h:295
DtIpcRdWrLock__rti__ * myRdWrLock
Definition: vlShmSubscribableMessageQueue__rti__.h:297
#define DtSM_INVALID_SUBSCRIBER_ID
Definition: vlShmSubscribableMessageQueue__rti__.h:37
DO NOT - REPEAT - DO NOT use critical sections in lieu of named mutexes in Win32 implementations.
Definition: vlIpcMutex__rti__.h:43
MAKRti::DtU32 outstandingReadCount
sequence number (assigned by sender)
Definition: vlShmSubscribableMessageQueue__rti__.h:325
MAKRti::DtU32 state
Definition: vlShmSubscribableMessageQueue__rti__.h:341
Contains classes which manage and view a shared memory pool in a platform independant way...
DtBucketHeader is a structure found at the front of each message to keep track of the number of bytes...
Definition: vlShmSubscribableMessageQueue__rti__.h:321
This is an abstract base class presenting an interface for a simple message queue.
Definition: vlShmMessageQueue__rti__.h:23
unsigned int theMaxSubscribers
The maximum number of subscribers allowed in this queue.
Definition: vlShmSubscribableMessageQueue__rti__.h:309
Platform independent read-lock / write-lock.
Definition: vlIpcRdWrLock__rti__.h:38
DtSharedMemoryPoolClient__rti__ * myShmPool
!WIN32
Definition: vlShmSubscribableMessageQueue__rti__.h:293
MAKRti::DtU32 myMessagesSentCnt
Definition: vlShmSubscribableMessageQueue__rti__.h:296
MAKRti::DtU32 msgSn
the ID of the subscriber
Definition: vlShmSubscribableMessageQueue__rti__.h:324
std::vector< char > myReadBuffer
Definition: vlShmSubscribableMessageQueue__rti__.h:299
DtIpcMutex__rti__ * myOrcMutex
Definition: vlShmSubscribableMessageQueue__rti__.h:298
#define DtSmSubMsgQ_theMaxSubscribers
TO DO – DAA workaround for MSVC6 bug ID #241569 A bug in MSVC++6 prevents initializing a static const...
Definition: vlShmSubscribableMessageQueue__rti__.h:50
MAKRti::DtU32 myDefaultReadMask
Definition: vlShmSubscribableMessageQueue__rti__.h:300
#define DT_DLL_RTIUTIL
Definition: rtiMsConfig.h:160
MAKRti::DtU32 back
Definition: vlShmSubscribableMessageQueue__rti__.h:347
DtQueueHeader exists at the front of the message queue and contains useful information about the stat...
Definition: vlShmSubscribableMessageQueue__rti__.h:339
DtSharedMemoryPoolClient__rti__ is used to attach to and access a previously created memory pool...
Definition: vlShmPool__rti__.h:107
MAKRti::DtU32 senderId
Definition: vlShmSubscribableMessageQueue__rti__.h:323
MAKRti::DtU32 numberOfBuckets
Definition: vlShmSubscribableMessageQueue__rti__.h:343
pthread_mutex_t ptOrcMutex
Definition: vlShmSubscribableMessageQueue__rti__.h:353

Document ID: Generated on Wed Jul 8 16:20:32 EDT 2026 from SVN revision 291616
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)