2020-07-09 14:26:15 +02:00
|
|
|
#include <framework/container/SharedRingBuffer.h>
|
|
|
|
#include <framework/ipc/MutexFactory.h>
|
|
|
|
#include <framework/ipc/MutexHelper.h>
|
|
|
|
|
2020-07-09 15:47:50 +02:00
|
|
|
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, const size_t size,
|
2020-08-04 02:25:10 +02:00
|
|
|
bool overwriteOld, size_t maxExcessBytes, dur_millis_t mutexTimeout):
|
|
|
|
SystemObject(objectId), SimpleRingBuffer(size, overwriteOld,
|
2020-08-08 23:45:18 +02:00
|
|
|
maxExcessBytes) {
|
2020-07-09 14:26:15 +02:00
|
|
|
mutex = MutexFactory::instance()->createMutex();
|
|
|
|
}
|
|
|
|
|
2020-07-09 15:47:50 +02:00
|
|
|
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer,
|
2020-08-04 02:25:10 +02:00
|
|
|
const size_t size, bool overwriteOld, size_t maxExcessBytes,
|
|
|
|
dur_millis_t mutexTimeout):
|
|
|
|
SystemObject(objectId), SimpleRingBuffer(buffer, size, overwriteOld,
|
2020-08-08 23:45:18 +02:00
|
|
|
maxExcessBytes) {
|
2020-07-09 14:26:15 +02:00
|
|
|
mutex = MutexFactory::instance()->createMutex();
|
|
|
|
}
|
|
|
|
|
2020-08-08 23:45:18 +02:00
|
|
|
ReturnValue_t SharedRingBuffer::lockRingBufferMutex(
|
|
|
|
MutexIF::TimeoutType timeoutType, dur_millis_t timeout) {
|
|
|
|
return mutex->lockMutex(timeoutType, timeout);
|
2020-08-04 02:25:10 +02:00
|
|
|
}
|
|
|
|
|
2020-08-08 23:45:18 +02:00
|
|
|
ReturnValue_t SharedRingBuffer::unlockRingBufferMutex() {
|
|
|
|
return mutex->unlockMutex();
|
2020-07-09 14:26:15 +02:00
|
|
|
}
|
|
|
|
|
2020-08-08 23:45:18 +02:00
|
|
|
MutexIF* SharedRingBuffer::getMutexHandle() const {
|
|
|
|
return mutex;
|
2020-07-09 14:26:15 +02:00
|
|
|
}
|