Add a copy of CircularWindowIterators to the ClientNotificationData of the DataReadyQueue
When inserting a new ID to the queue, create a real copies of all CircularWindowIterator
s which participate in that 'client update' and save these copies in the ClientNotificationData
.
- It would not be required any more to validate windows after each push (
CircularBufferManagerBase::validateWindows
) - The client which copies the data from the window can do the validation
- Since we don't know when/if clients will act on new queue elements, the Lifetime of the new
CircularWindowIterator
copies would be bound to the length of the usedDataReadyQueue
. When the oldest queue element is dropped, as well isCircularWindowIterator
s will be released - Windows would not need to have a
valid_
flag anymore
From #31 (closed):
When readout is complete we need to determine if the data is still valid. This would be done by comparing the write head & wraparound counter at the time before sending the window and at the time of readout completion. This way we can detect validity of the data.
Generally agreed. I think after #58 (closed) it should even be sufficient to only validate after readout completion.
This does mean that we need to synchronize the access to the write head (iterator) and the wraparound counter (
n_data_pushed_total_
) and as such a mutex.
I think we even can prevent that by incrementing n_data_pushed_total_
inside 'CircularBuffer*::push( ... )' operations before doing the actual memcpy
. n_data_pushed_total_
would need to be atomic for that, I suppose.
So when reading n_data_pushed_total_
after readout completion and the check still passes, we could be sure that no samples got overwritten during the readout.
As far as I can see, the only drawback would be, that it theoretically can happen that our window will be flagged invalid, even though the memcpy
was not done yet. However, that is a rather theoretical use-case, which anyhow would require the write-iterator to first do a full round-trip on the buffer.
You see any problems for doing window validation like that @m.marn ?