sipxportlib  Version 3.3
OsMsgQShared.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _OsMsgQShared_h_
13 #define _OsMsgQShared_h_
14 
15 // SYSTEM INCLUDES
16 
17 // APPLICATION INCLUDES
18 #include "os/OsCSem.h"
19 #include "os/OsDefs.h"
20 #include "os/OsMsg.h"
21 #include "os/OsMsgQ.h"
22 #include "os/OsMutex.h"
23 #include "os/OsTime.h"
24 #include "utl/UtlDList.h"
25 
26 // DEFINES
27 // MACROS
28 // EXTERNAL FUNCTIONS
29 // EXTERNAL VARIABLES
30 // CONSTANTS
31 // STRUCTS
32 // TYPEDEFS
33 class UtlString;
34 
35 // FORWARD DECLARATIONS
36 
37 // #define OS_MSGQ_DEBUG
38 // #define OS_MSGQ_REPORTING
39 
40 // debug class
42 {
43  public:
44  DebugMutex(OsMutex& mutex, const char* label)
45  {
46  printf("DebugMutex %s:\n", label);
47  mutex.OsMutexShow();
48  };
49 
50  private:
51  DebugMutex();
52 };
53 
80 class OsMsgQShared : public OsMsgQBase
81 {
82 /* //////////////////////////// PUBLIC //////////////////////////////////// */
83 public:
84 
85 /* ============================ CREATORS ================================== */
86 
89  const int maxMsgs=DEF_MAX_MSGS,
90  const int maxMsgLen=DEF_MAX_MSG_LEN,
91  const int options=Q_PRIORITY,
92  const UtlString& name=""
93  );
98  virtual ~OsMsgQShared();
100 
101 /* ============================ MANIPULATORS ============================== */
102 
104  virtual OsStatus send(const OsMsg& rMsg,
105  const OsTime& rTimeout=OsTime::OS_INFINITY);
106 
108  virtual OsStatus sendNoCopy(OsMsg *pMsg,
109  const OsTime& rTimeout=OsTime::OS_INFINITY);
110 
112  virtual OsStatus sendUrgent(const OsMsg& rMsg,
113  const OsTime& rTimeout=OsTime::OS_INFINITY);
114 
116  virtual OsStatus sendFromISR(OsMsg& rMsg);
117 
119  virtual OsStatus receive(OsMsg*& rpMsg,
120  const OsTime& rTimeout=OsTime::OS_INFINITY);
121 
122 /* ============================ ACCESSORS ================================= */
123 
124 #ifdef OS_MSGQ_DEBUG
125  int getFullCount() { return mFull.getValue();}
126  int getEmptyCount() { return mEmpty.getValue();}
127  UtlDList& getList() { return mDlist;}
128 #endif
129 
131  virtual int numMsgs();
132 
133 #ifdef MSGQ_IS_VALID_CHECK
134  virtual void show();
136 #endif
137 
138 /* ============================ INQUIRY =================================== */
139 
140 /* //////////////////////////// PROTECTED ///////////////////////////////// */
141 protected:
142 
143 #ifdef MSGQ_IS_VALID_CHECK
144  virtual void testMessageQ();
145 #endif
146 
147 
148 /* //////////////////////////// PRIVATE /////////////////////////////////// */
149 private:
150  OsMutex mGuard;
151  OsCSem mEmpty;
152  OsCSem mFull;
155  UtlDList mDlist;
158 
159 #ifdef MSGQ_IS_VALID_CHECK
160  int mOptions;
161  int mHighCnt;
162 #endif
163 
164 #ifdef OS_MSGQ_REPORTING
165  int mIncreaseLevel;
166  int mDecreaseLevel;
168  int mIncrementLevel;
170 #endif
173 
175  OsStatus doSend(const OsMsg& rMsg, const OsTime& rTimeout,
176  const UtlBoolean isUrgent, const UtlBoolean needCopy);
177 
179  OsStatus doReceive(OsMsg*& rpMsg, const OsTime& rTimeout);
180 
182  OsMsgQShared(const OsMsgQShared& rOsMsgQShared);
183 
185  OsMsgQShared& operator=(const OsMsgQShared& rhs);
186 
187 };
188 
189 /* ============================ INLINE METHODS ============================ */
190 
191 #endif // _OsMsgQShared_h_
192 
Definition: OsMsgQShared.h:80
OsStatus
Definition: OsStatus.h:27
DebugMutex(OsMutex &mutex, const char *label)
Definition: OsMsgQShared.h:44
Definition: UtlString.h:48
Definition: OsMsgQShared.h:41
Definition: OsTime.h:45
Definition: OsTime.h:37
int UtlBoolean
Definition: UtlDefs.h:41
Definition: OsMsg.h:36
Definition: UtlDList.h:36
Definition: OsMsgQ.h:38