Closed GPMueller closed 3 years ago
A solution to this might be to change the locking procedures.
Instead of locking the parameters etc. which reside within the images and chain, the Method
could copy parameters over from the State
if a corresponding increment shows that they changed.
This would allow the separation of the write and read accesses, preventing most blocking caused by colliding mutex locking calls.
Should take some inspiration from http://blog.vorbrodt.me/?p=409
This might be a good library to use for thread-safety: https://github.com/LouisCharlesC/safe It is described quite nicely here: https://www.fluentcpp.com/2019/04/26/how-to-write-safe-and-expressive-multi-threaded-code-in-cpp11/
However, I don't see how to get rid of the issues of lagging GUIs when variables are accessed rapidly during a simulation (see #144).
This might be a nice library for a lock queue: https://github.com/max0x7ba/atomic_queue and this might be a good read: http://alinloghin.com/articles/command_buffer.html
Closing as PR #558 has been merged.
Potentially, some parts of the design won't allow this, but it would be best to use scoped locks instead of manual
lock
/unlock
calls, see also http://kayari.org/cxx/antipatterns.html#locking-mutexOne question is, whether images need to be locked when the chain is manipulated - and if yes, then how?