PickNikRobotics / data_tamer

C++ library for Fearless Timeseries Logging
MIT License
219 stars 21 forks source link

Question about real time safety of snapshot call #10

Closed jlack1987 closed 10 months ago

jlack1987 commented 10 months ago

This isn't an issue more of just a question about the snapshot call. I see a lock there so i'm assuming it's not considered a real time safe call? If i'm mistaken could you maybe comment further on it or if you have any future plans to address it? Thanks!

facontidavide commented 10 months ago

It SHOULD be real time safe.

The mutex used shouldn't be affected by priority inversion. https://github.com/PickNikRobotics/data_tamer/blob/main/data_tamer_cpp/include/data_tamer/details/mutex.hpp

This should be enough to make it safe in the real-time context.

Also, when used as recomended, i.e. registering all your variable once before calling takeSnapshot, the mutex will always be unlocked.

On the other hand, I don't think you should call takeSnapshot from different threads (why would you do that?)

So, I did my best to make this a thread-safe and real-time safe as possible, but if you see any issue, please let me knoe.