9 #ifndef CLUON_SHAREDMEMORY_HPP 10 #define CLUON_SHAREDMEMORY_HPP 13 #include "cluon/cluonDataStructures.hpp" 48 SharedMemory(
const std::string &name, uint32_t size = 0) noexcept;
54 bool isLocked()
const noexcept;
64 void unlock() noexcept;
74 void notifyAll() noexcept;
86 bool setTimeStamp(
const cluon::data::TimeStamp &ts) noexcept;
95 std::pair<bool, cluon::data::TimeStamp> getTimeStamp() noexcept;
101 bool valid() noexcept;
106 char *data() noexcept;
111 uint32_t size()
const noexcept;
116 const std::string name()
const noexcept;
120 void initWIN32() noexcept;
121 void deinitWIN32() noexcept;
122 void lockWIN32() noexcept;
123 void unlockWIN32() noexcept;
124 void waitWIN32() noexcept;
125 void notifyAllWIN32() noexcept;
128 void initPOSIX() noexcept;
129 void deinitPOSIX() noexcept;
130 void lockPOSIX() noexcept;
131 void unlockPOSIX() noexcept;
132 void waitPOSIX() noexcept;
133 void notifyAllPOSIX() noexcept;
134 bool validPOSIX() noexcept;
136 void initSysV() noexcept;
137 void deinitSysV() noexcept;
138 void lockSysV() noexcept;
139 void unlockSysV() noexcept;
140 void waitSysV() noexcept;
141 void notifyAllSysV() noexcept;
142 bool validSysV() noexcept;
146 std::string m_name{
""};
147 std::string m_nameForTimeStamping{
""};
149 char *m_sharedMemory{
nullptr};
150 char *m_userAccessibleSharedMemory{
nullptr};
151 bool m_hasOnlyAttachedToSharedMemory{
false};
153 std::atomic<bool> m_broken{
false};
154 std::atomic<bool> m_isLocked{
false};
157 HANDLE __conditionEvent{
nullptr};
158 HANDLE __mutex{
nullptr};
159 HANDLE __sharedMemory{
nullptr};
161 int32_t m_fdForTimeStamping{-1};
163 bool m_usePOSIX{
true};
166 #if !defined(__NetBSD__) && !defined(__OpenBSD__) 168 struct SharedMemoryHeader {
170 pthread_mutex_t __mutex;
171 pthread_cond_t __condition;
173 SharedMemoryHeader *m_sharedMemoryHeader{
nullptr};
177 key_t m_shmKeySysV{0};
178 key_t m_mutexKeySysV{0};
179 key_t m_conditionKeySysV{0};
181 int m_sharedMemoryIDSysV{-1};
182 int m_mutexIDSysV{-1};
183 int m_conditionIDSysV{-1};
#define LIBCLUON_API
Definition: cluon.hpp:56
Definition: SharedMemory.hpp:32