Possible raise condition while moving data windows
pushBackDataFinished
which is used for window movement is called by the same thread which pushes data.
Though reading the data from a window is done in a different thread. In order to prevent concurrent access, the following measure needs to be done. Two possible solutions:
Solution 1:
- Use a
std::mutex
for window movement and readout- Whenever the window is moved or modified ... required to expose mutex lock/unlock in order dont toggle it to frequently during movement / update of metadata
- Whenever the windoe is read out
Solution 2:
- Create a copy of the window after each movement
- Pass that copy to the DataReadyQueue, though keep a reference in BufferManager in order to invalidate it on each subsequent move operation of the write iterator. (mutex protected
valid_
flag) - Once a window is invalidated, there is no need to further track it in the BufferManager.
I think Solution 2 would be more elegant. An unfinished attempt (meanwhile conflicting) can be seen here: https://gitlab.com/al.schwinn/cabad/-/tree/%2331_pass_copied_window_to_client
Edited by al.schwinn