Added possibility to set a pre save callback #199
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows the
BufferManagerusers to know when a mat file is about to be saved. This is to synchronize with other logging tools. Before this PR there was no way to understand when thematfile was about to be saved when the periodic save is on. More importantly, thesaveToFilemethod does not prevent any concurrentpush_backon the channels, since it does not lock any mutex. This means that if we have a series of channels that we want to be aligned, when pushing to the channels sequentially, some data could end in one file, and other data in the next one. While we are not loosing any data, this could lead to channels of different lengths within a file (I think this is also something that @valegagge and @PasMarra experienced once).On our side, in the
BipedalLocomotionFramework::YarpRobotLoggerDevicewe store a set of images periodically in a different thread. We also periodically push to the buffer manager the corresponding frame timestamp. In this case, this callback is even more important, because if the periodic save of the mat file is triggered, we can keep saving frames in the corresponding folder and push the timestamp to the buffer manager, and we don't realize it until the saving is completed. This means that the frames stored while the mat file was being saved will be stored in a folder with the name of the mat file being just saved, but the corresponding timestamps are saved in the next file.This pre save callback allows to notify the buffer manager user that the file is about to be save, and also delaying or cancel its saving if necessary.
cc @GiulioRomualdi @traversaro