18 #ifndef __esynch2_h_included 19 #define __esynch2_h_included 58 _esynchcontrol_t m_semaphoreCtrl;
59 _esynchcontrol_t m_mutexCtrl;
68 Bool m_multipleReaders;
69 Bool m_multipleWriters;
75 virtual Int
getInitType() {
return STATIC_INIT_TYPE_PRIORITY; }
79 Void logObjectUsage();
81 static Int nextSemaphore();
82 static Int nextMutex();
84 static Void freeSemaphore(Int nSemId);
85 static Void freeMutex(Int nMutexId);
87 Long incSequence() {
return atomic_inc(m_pCtrl->m_sequence); }
89 epublicqueuedef_t *getPublicQueue(Int queueid)
91 for (
int i = 0; m_pPubQueues[i].m_name[0] != 0; i++)
93 if (m_pPubQueues[i].m_queueid == queueid)
94 return &m_pPubQueues[i];
100 Void setPublicQueue(Int idx, cpChar pName, Int queueid, Int msgSize,
101 Int msgCnt, Bool multipleReaders, Bool multipleWriters)
103 epc_strcpy_s(m_pPubQueues[idx].m_name,
sizeof(m_pPubQueues[idx].m_name), pName);
104 m_pPubQueues[idx].m_queueid = queueid;
105 m_pPubQueues[idx].m_msgSize = msgSize;
106 m_pPubQueues[idx].m_msgCnt = msgCnt;
107 m_pPubQueues[idx].m_multipleReaders = multipleReaders;
108 m_pPubQueues[idx].m_multipleWriters = multipleWriters;
114 throw ESynchObjectsError_PublicObjectsNotEnabled();
118 static ESemaphoreDataPublic &getSemaphore(Int ofs)
121 throw ESynchObjectsError_InvalidOffset();
122 return getSynchObjCtrlPtr()->m_pSemaphores[ofs - 1];
125 static EMutexDataPublic &getMutex(Int ofs)
128 throw ESynchObjectsError_InvalidOffset();
129 return getSynchObjCtrlPtr()->m_pMutexes[ofs - 1];
146 ESynchObjectsSharedMemory m_sharedmem;
147 esynchcontrol_t *m_pCtrl;
148 ESemaphoreDataPublic *m_pSemaphores;
149 EMutexDataPublic *m_pMutexes;
150 epublicqueuedef_t *m_pPubQueues;
155 #endif // #define __esynch2_h_included #define atomic_inc(a)
atomic increment - increments a by 1
Definition: eatomic.h:27
Performs static initialization associated with any EpcTools class that requires it. Initialization and uninitialization is performed by EpcTools::Initialize() and EpcTools::UnInitialize().
virtual Void uninit()
Performs uninitialization at system shutdown.
Definition: estatic.h:63
Defines a class for access to shared memory.
The shared memory access class.
Definition: eshmem.h:43
Any EpcTools that needs to have initialization performed as part of EpcTools::Initialize() should der...
Definition: estatic.h:51
virtual Int getInitType()
Definition: estatic.h:57
Macros for performing CPU atomic/interlaced operations.
virtual Void init(EGetOpt &opt)
Performs class specific initialization.
Definition: estatic.h:61
#define epc_strcpy_s(strDestination, sizeInBytes, strSource)
epc_strcpy_s - strncpy
Definition: ebase.h:50
Used internally by EpcTools for managing access to public (shared memory) objects.
Definition: esynch2.h:41
DECLARE_ERROR(ESynchObjectsError_PublicObjectsNotEnabled)
#define EPC_FILENAME_MAX
maximum file name length
Definition: ebase.h:37
A private mutex (the mutex data is allocated from either the heap or stack).
Definition: esynch.h:175
DECLARE_ERROR_ADVANCED2(ESynchObjectsError_UnableToAllocateSynchObject)
Contains definitions for synchronization objects.