Use n_data_pushed_total_ for window validation
Current approach
Currently, CircularBufferBase::was_overwritten
is used in order to check after each write if a data window was overwritten.
It does that by storing the previous write iterator and the current write iterator. If any sample of the data window is located in between, the window is considered to be overwritten.
The problem with that approach is, that an extra variable previous_write_iterator_
needs to be maintained.
New approach
The absolute number of samples ever pushed to the buffer is stored inside CircularBufferBase::n_data_pushed_total_
. That is as well the absolute position of the write iterator (= wrap around counter + position of the write head).
After moving a CircularWindowIterator, we can store the absolute position of the window (first sample of the window) by copying the current CircularBufferBase::n_data_pushed_total_
. On validation, we can use that value to check if the write iter passed the window again.
Pseudo code:
if (absPosWindow + BuffSize < absPosWriteIter)
window_valid = false;
Like that, previous_write_iterator_
can be dropped.