VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlShmQueue.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 MAK Technologies, Inc
3 ** All rights reserved.
4 *********************************************************************/
8 #pragma once
9 
10 #include "vlMachineTypes.h"
11 
12 #include <sys/types.h>
13 #include <sys/ipc.h>
14 #include <sys/sem.h>
15 
17 #define DT_QCONTROL_VALID 0
18 #define DT_QCONTROL_DEAD_SPACE 1
19 #define DT_QCONTROL_END 2
20 
21 #define DtSMQFrontLockSem 0
22 #define DtSMQPacketCountSem 1
23 
28 #define DtSMQByteCountSem 0
29 
30 #define DtCsSemaphoresUsed 2
31 
32 #define DtSMQDontGoYet 0
33 #define DtSMQIAmGoingAway 1
34 #define DtSMQYouMustGoAway 2
35 
36 #define DtSMQExternal 0
37 #define DtSMQInternal 1
38 
39 #ifdef DtUSE_UTILITIES_NAMESPACE
40 namespace DtUSE_UTILITIES_NAMESPACE
41 {
42 #endif
43 
44 typedef struct Dt_Q_Elmt_Hdr
45 {
46  short read;
47  short control;
48  int size;
50 
51 typedef struct Dt_Msg_Queue_Element
52 {
54  char data[8];
56 
57 
58 typedef struct Dt_Q_Hdr
59 {
62 
64  unsigned char goAway;
65  unsigned char internal;
67 
68  unsigned char blockingRead;
69  unsigned char blockingWrite;
70  unsigned char dropOldest;
71  unsigned char padding2;
72 
74 
75 typedef struct Dt_Shm_Msg_Queue
76 {
78  char data[8];
80 
81 
82 
84 {
85  friend class DtShmMsgQueueReader;
86  friend class DtShmMsgQueueWriter;
87 
88  public:
89 
90  DtShmMsgQueueManager(DtShmMsgQueue *q, int size, int sem, int firstSem,
91  bool pleaseInit, bool dropOldest);
92 
93  virtual ~DtShmMsgQueueManager(void);
94 
95  void setBlockingRead(bool mode)
96  { queue->hdr.blockingRead = mode ? 1 : 0; }
97 
98  void setBlockingWrite(bool mode)
99  { queue->hdr.blockingWrite = mode ? 1 : 0; }
100 
102  { return queue->hdr.blockingRead ? true : false; }
103 
105  { return queue->hdr.blockingWrite ? true : false; }
106 
107  bool isDropOldest()
108  { return queue->hdr.dropOldest ? true : false; }
109 
110  int getGoAway() { return queue->hdr.goAway; }
111 
112  DtU32 notifyReader();
113 
114  void setNotifyReader(DtU32 count) { queue->hdr.notifyReader = count; }
115 
116  private:
117 
118  int lockFront(int wait);
119  void unlockFront(void);
120 
121  void incrPacketCount(int amount);
122  void incrByteCount(int amount);
123  void decrByteCount(int amount);
124  void decrPacketCount(int amount);
125 
126  int getPhysEnd() { return physEnd; }
127 
128  void setFront(int newFront) { queue->hdr.front = newFront; }
129  int getFront() { return queue->hdr.front; }
130 
131  void setGoAway(int reason) { queue->hdr.goAway = reason; }
132 
133  void setDropOldest(bool mode)
134  { queue->hdr.dropOldest = mode ? 1 : 0; }
135 
136  void setInternal(int mode) { queue->hdr.internal = mode; }
137  bool isInternal() { return queue->hdr.internal ? true : false; }
138 
140  { return (DtMsgQueueElement *) & queue->data[i]; }
141 
142 
143  protected:
144 
146  int physEnd;
147  int semid;
148 
149  struct sembuf testAndSetLock;
150  struct sembuf clearLock;
151  struct sembuf addBytes;
152  struct sembuf subBytes;
153  struct sembuf addPackets;
154  struct sembuf subPackets;
155 
156 
157 };
158 
159 #ifdef DtUSE_UTILITIES_NAMESPACE
160 }
161 #endif
162 
void setFront(int newFront)
Definition: vlShmQueue.h:128
Definition: vlShmQueue.h:75
DtU16 padding1
Definition: vlShmQueue.h:66
short read
Definition: vlShmQueue.h:46
unsigned char dropOldest
Definition: vlShmQueue.h:70
struct Dt_Msg_Queue_Element DtMsgQueueElement
struct Dt_Shm_Msg_Queue DtShmMsgQueue
unsigned char padding2
Definition: vlShmQueue.h:71
short control
Definition: vlShmQueue.h:47
bool isBlockingRead()
Definition: vlShmQueue.h:101
void setNotifyReader(DtU32 count)
Definition: vlShmQueue.h:114
unsigned char blockingWrite
Definition: vlShmQueue.h:69
struct Dt_Q_Hdr DtShmQueueHdr
DtQueueElementHdr hdr
Definition: vlShmQueue.h:53
void setBlockingWrite(bool mode)
Definition: vlShmQueue.h:98
bool isInternal()
Definition: vlShmQueue.h:137
void setInternal(int mode)
Definition: vlShmQueue.h:136
bool isDropOldest()
Definition: vlShmQueue.h:107
DtU32 notifyReader
Definition: vlShmQueue.h:61
int getPhysEnd()
Definition: vlShmQueue.h:126
Definition: vlShmQueue.h:44
DtShmMsgQueue * queue
Definition: vlShmQueue.h:145
Definition: vlShmQueue.h:83
bool isBlockingWrite()
Definition: vlShmQueue.h:104
unsigned char blockingRead
Definition: vlShmQueue.h:68
int size
Definition: vlShmQueue.h:48
DtInt32 front
Definition: vlShmQueue.h:60
Definition: vlShmReader.h:43
Definition: vlShmWriter.h:30
DtShmQueueHdr hdr
Definition: vlShmQueue.h:77
struct Dt_Q_Elmt_Hdr DtQueueElementHdr
int physEnd
Definition: vlShmQueue.h:146
void setDropOldest(bool mode)
Definition: vlShmQueue.h:133
int getFront()
Definition: vlShmQueue.h:129
DtMsgQueueElement * getQueueElement(int i)
Definition: vlShmQueue.h:139
unsigned short DtU16
A 16 bit unsigned integer value.
Definition: vlMachineTypes.h:140
Definition: vlShmQueue.h:51
Definition: vlShmQueue.h:58
int getGoAway()
Definition: vlShmQueue.h:110
char data[8]
Definition: vlShmQueue.h:54
int semid
Definition: vlShmQueue.h:147
long int DtInt32
A 32 bit integer value.
Definition: vlMachineTypes.h:156
unsigned long DtU32
A 32 bit unsigned integer value.
Definition: vlMachineTypes.h:153
This file contains typedefs for machine dependant types.
void setBlockingRead(bool mode)
Definition: vlShmQueue.h:95
unsigned char goAway
Messages read by the reader.
Definition: vlShmQueue.h:64
void setGoAway(int reason)
Definition: vlShmQueue.h:131
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109

Document ID: Generated on Wed Mar 27 02:04:30 EDT 2024 from SVN revision 264570
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)