shared ring buffer continued
This commit is contained in:
parent
4e9e465360
commit
6b475792a4
@ -3,19 +3,26 @@
|
|||||||
#include <framework/ipc/MutexHelper.h>
|
#include <framework/ipc/MutexHelper.h>
|
||||||
|
|
||||||
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, const size_t size,
|
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, const size_t size,
|
||||||
bool overwriteOld, dur_millis_t mutexTimeout):
|
bool overwriteOld, size_t maxExcessBytes, dur_millis_t mutexTimeout):
|
||||||
SystemObject(objectId), SimpleRingBuffer(size, overwriteOld),
|
SystemObject(objectId), SimpleRingBuffer(size, overwriteOld,
|
||||||
mutexTimeout(mutexTimeout) {
|
maxExcessBytes), mutexTimeout(mutexTimeout) {
|
||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer,
|
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer,
|
||||||
const size_t size, bool overwriteOld, dur_millis_t mutexTimeout):
|
const size_t size, bool overwriteOld, size_t maxExcessBytes,
|
||||||
SystemObject(objectId), SimpleRingBuffer(buffer, size, overwriteOld),
|
dur_millis_t mutexTimeout):
|
||||||
mutexTimeout(mutexTimeout) {
|
SystemObject(objectId), SimpleRingBuffer(buffer, size, overwriteOld,
|
||||||
|
maxExcessBytes), mutexTimeout(mutexTimeout) {
|
||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t SharedRingBuffer::getFreeElementProtected(uint8_t** writePtr,
|
||||||
|
size_t amount) {
|
||||||
|
MutexHelper(mutex, mutexTimeout);
|
||||||
|
return SimpleRingBuffer::getFreeElement(writePtr,amount);
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t SharedRingBuffer::writeDataProtected(const uint8_t *data,
|
ReturnValue_t SharedRingBuffer::writeDataProtected(const uint8_t *data,
|
||||||
size_t amount) {
|
size_t amount) {
|
||||||
MutexHelper(mutex, mutexTimeout);
|
MutexHelper(mutex, mutexTimeout);
|
||||||
|
@ -17,7 +17,8 @@ public:
|
|||||||
* will be overwritten.
|
* will be overwritten.
|
||||||
*/
|
*/
|
||||||
SharedRingBuffer(object_id_t objectId, const size_t size,
|
SharedRingBuffer(object_id_t objectId, const size_t size,
|
||||||
bool overwriteOld, dur_millis_t mutexTimeout = 10);
|
bool overwriteOld, size_t maxExcessBytes,
|
||||||
|
dur_millis_t mutexTimeout = 10);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor takes an external buffer with the specified size.
|
* This constructor takes an external buffer with the specified size.
|
||||||
@ -28,10 +29,14 @@ public:
|
|||||||
* will be overwritten.
|
* will be overwritten.
|
||||||
*/
|
*/
|
||||||
SharedRingBuffer(object_id_t objectId, uint8_t* buffer, const size_t size,
|
SharedRingBuffer(object_id_t objectId, uint8_t* buffer, const size_t size,
|
||||||
bool overwriteOld, dur_millis_t mutexTimeout = 10);
|
bool overwriteOld, size_t maxExcessBytes,
|
||||||
|
dur_millis_t mutexTimeout = 10);
|
||||||
|
|
||||||
void setMutexTimeout(dur_millis_t newTimeout);
|
void setMutexTimeout(dur_millis_t newTimeout);
|
||||||
|
|
||||||
|
/** Performs mutex protected SimpleRingBuffer::getFreeElement call */
|
||||||
|
ReturnValue_t getFreeElementProtected(uint8_t** writePtr, size_t amount);
|
||||||
|
|
||||||
/** Performs mutex protected SimpleRingBuffer::writeData call */
|
/** Performs mutex protected SimpleRingBuffer::writeData call */
|
||||||
ReturnValue_t writeDataProtected(const uint8_t* data, size_t amount);
|
ReturnValue_t writeDataProtected(const uint8_t* data, size_t amount);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user