Added reset() method to RingBuffer class

pull/236/head
Silvano Seva 2024-01-27 11:51:22 +01:00
rodzic 275ef16977
commit 90cf0f6f58
1 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -175,6 +175,20 @@ public:
pthread_mutex_unlock(&mutex);
}
/**
* Reset the buffer to its empty state discarding all the elements stored.
*
* Note: reset is "lazy", as it just sets read pointer, write pointer and
* number of elements to zero. No actual erasure of the stored elements is
* done until they are effectively overwritten by new push()es.
*/
void reset()
{
readPos = 0;
writePos = 0;
numElements = 0;
}
private:
size_t readPos; ///< Read pointer.