EpcTools
An event based multi-threaded C++ development framework.
eqpriv.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2009-2019 Brian Waters
3 * Copyright (c) 2019 Sprint
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 
18 #ifndef __eqpriv_h_included
19 #define __eqpriv_h_included
20 
23 
24 #include "eqbase.h"
25 
27 class EQueuePrivate : virtual public EQueueBase
28 {
29 public:
31  EQueuePrivate();
34 
42  Void init(Int nMsgSize, Int nMsgCnt, Int queueId, Bool bMultipleReaders,
43  Bool bMultipleWriters, EQueueBase::Mode eMode)
44  {
45  EQueueBase::init(nMsgSize, nMsgCnt, queueId, bMultipleReaders, bMultipleWriters, eMode);
46  }
47 
48 protected:
50  Bool isPublic() { return False; }
51  ULong &msgSize();
52  Int &msgCnt();
53  Long &msgHead();
54  Long &msgTail();
55  Bool &multipleReaders();
56  Bool &multipleWriters();
57  Int &numReaders();
58  Int &numWriters();
59  Int &refCnt();
60  pChar data();
61  Int ctrlSize();
62  Void allocDataSpace(cpStr sFile, Char cId, Int nSize);
63  Void initReadMutex();
64  Void initWriteMutex();
65  Void initSemFree(UInt initialCount);
66  Void initSemMsgs(UInt initialCount);
67 
68  EMutexData &readMutex() { return m_rmutex; }
69  EMutexData &writeMutex() { return m_wmutex; }
70  ESemaphoreData &semFree() { return m_semFree; }
71  ESemaphoreData &semMsgs() { return m_semMsgs; }
72 
73  virtual EQueueMessage *allocMessage(Long msgType) = 0;
75 
76 private:
77  Int m_refCnt;
78  Int m_numReaders;
79  Int m_numWriters;
80  Bool m_multipleReaders;
81  Bool m_multipleWriters;
82 
83  ULong m_msgSize;
84  Int m_msgCnt;
85  Long m_head; // next location to write
86  Long m_tail; // next location to read
87 
88  EMutexPrivate m_rmutex;
89  EMutexPrivate m_wmutex;
90  ESemaphorePrivate m_semFree;
91  ESemaphorePrivate m_semMsgs;
92 
93  pChar m_pData;
94 };
95 
96 #endif // #define __eqpriv_h_included
ESemaphoreData
Contains the data associated with a public or private semaphore.
Definition: esynch.h:268
EQueueBase
The message queue base class.
Definition: eqbase.h:120
EQueueMessage
Represents a message to be written to/read from a message queue.
Definition: eqbase.h:55
EMutexPrivate
A private mutex (the mutex data is allocated from either the heap or stack).
Definition: esynch.h:175
EQueueBase::Mode
Mode
The queue access modes.
Definition: eqbase.h:127
False
#define False
False.
Definition: ebase.h:27
EQueuePrivate
The private queue class.
Definition: eqpriv.h:27
ESemaphorePrivate
Represents a private semaphore, the semaphore data is allocated from either the stack or heap.
Definition: esynch.h:382
EQueuePrivate::EQueuePrivate
EQueuePrivate()
Default constructor.
Definition: eqpriv.cpp:20
EQueuePrivate::init
Void init(Int nMsgSize, Int nMsgCnt, Int queueId, Bool bMultipleReaders, Bool bMultipleWriters, EQueueBase::Mode eMode)
Initializes the private message queue.
Definition: eqpriv.h:42
eqbase.h
Provides base class support for sending and receiving messages via a message queue.
EQueuePrivate::~EQueuePrivate
~EQueuePrivate()
Class destructor.
Definition: eqpriv.cpp:34
EMutexData
Contains the data associated with a public or private mutex.
Definition: esynch.h:72