Implemented client datasource
This commit is contained in:
@@ -42,6 +42,12 @@ public:
|
||||
*/
|
||||
void Write(float64 t, float64 v);
|
||||
|
||||
/**
|
||||
* @brief Write @p n (t, v) pairs in a single lock acquisition.
|
||||
* Much faster than calling Write() n times for large batches.
|
||||
*/
|
||||
void WriteBatch(const float64 *t, const float64 *v, uint32 n);
|
||||
|
||||
/**
|
||||
* @brief Copy the last (oldest-to-newest) min(n, count) points into tOut/vOut.
|
||||
* @return Number of points actually written.
|
||||
@@ -144,6 +150,22 @@ inline void SignalRingBuffer::Write(float64 t, float64 v) {
|
||||
mutex.FastUnLock();
|
||||
}
|
||||
|
||||
inline void SignalRingBuffer::WriteBatch(const float64 *t, const float64 *v,
|
||||
uint32 n) {
|
||||
if (n == 0u) { return; }
|
||||
(void) mutex.FastLock();
|
||||
if (capacity > 0u) {
|
||||
for (uint32 i = 0u; i < n; i++) {
|
||||
tBuf[head] = t[i];
|
||||
vBuf[head] = v[i];
|
||||
head = (head + 1u) % capacity;
|
||||
if (count < capacity) { count++; }
|
||||
}
|
||||
totalWritten += static_cast<MARTe::uint64>(n);
|
||||
}
|
||||
mutex.FastUnLock();
|
||||
}
|
||||
|
||||
inline uint32 SignalRingBuffer::Read(float64 *tOut, float64 *vOut, uint32 n) const {
|
||||
if ((capacity == 0u) || (count == 0u)) { return 0u; }
|
||||
(void) mutex.FastLock();
|
||||
|
||||
Reference in New Issue
Block a user