Hi everyone!
I do not have much experience with locking, and basically zero experience with locking in the JUCE framework, so I was hoping for some advice here. In my situation, there are two threads; the first thread is the Rendering-thread, which of course has a high priority (real-time) and the second thread is the Updating-thread, currently being the JUCE GUI-thread, which has a lower priority.
Now there is a data-structure, which is altered by the Updating-thread and read several times a second by the Rendering-thread. Updates are very fast (sub-microsecond), so what I’d like to have is that the Rendering-thread waits for the Updating-thread to complete it’s update. In this case, a spinlock seems ideal (right?) but I’m afraid that I might run into some priority inversion issues here (where the Updating-thread holds the lock but is never run due to the lower priority). Obviously I would like to stop the Updating-thread from starting new updates while the Rendering-thread is doing its’ thing too.
What would be the ideal solution/lock to fix this? Priority inheritance (temporarily upping the priority of the Updating-thread while it holds the lock) seems ideal here, but is this supported across all operating systems?
Currently I only have one Updating-threads, but I might have several in the future, would this solution be easily extendable?