7 #ifndef __ASYNC_MEMORY_BLOCK_HEADER
8 #define __ASYNC_MEMORY_BLOCK_HEADER
11 #include <condition_variable>
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
Thread safe smart pointer for raw memory blocks.
std::condition_variable m_CondNewData
condition_variable to signal a waiting writer that all readers finished
std::mutex m_mutexLock
mutex for short locks (like counter increments)
std::condition_variable m_CondEventNoReader
Mutex for locking the conditional variable depending on 'newData'.
std::recursive_mutex m_oMutexChangeState
number of writers which are waiting
tInt GetSize()
Get size of MemoryBlock.
tInt m_nSize
memory assigned not alloced (not to be freed afterwards)
std::condition_variable m_CondMutexLock
event to signal new data
tInt m_nWriterWaitCount
write access currently active
tResult Alloc(tInt nSize)
Allocates new memory for the MemoryBlock *.
tResult Assign(void *pMem, tInt nSize)
Assigns memory to the MemoryBlock object which has already been allocated.
std::mutex m_mutexNoReader
mutex for locking MemoryBlock for other access
tInt m_nReaderCount
memory size
tResult Free()
Lock MemoryBlock and free memory is allocated and not assigned *.
tBool m_bWriteAccess
count of active readers
tInt Compare(cAsyncMemoryBlock &oSrc)
Compares size and content with another MemoryBlock.
tResult WriteLock(void **ppMem, const tBool bWait=tTrue)
Try to lock memory for write access.
tBool m_bMemAssigned
memory pointer
virtual ~cAsyncMemoryBlock()
Destructor.
tResult ReadLock(void **ppMem, const tBool bWait=tTrue)
Try to lock memory for read access.
tResult WaitNewData(tInt nTimeout=-1)
Wait for the NewDataEvent which is set by unlocking a write access.
tResult Copy(cAsyncMemoryBlock &oSrc)
Copies the content of the source MemoryBlock.
std::mutex m_mutexNewData
Mutex for locking the condVariable depending on 'noReader'.
cAsyncMemoryBlock()
Default constructor.
tResult Unlock(void)
Unlock MemoryBlock.
A common result class usable as return value throughout.
#define tTrue
Value for tBool.
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.