Should I use SliderListener for component updates and ValueTree Listener for audio thread updates?

Except that the documentation for triggerUpdate() says:

It’s thread-safe to call this method from any thread, BUT beware of calling it from a real-time (e.g. audio) thread, because it involves posting a message to the system queue, which means it may block (and in general will do on most OSes).

I was recently working on that same issue, of how to trigger GUI updates from parameter changes (for stuff that’s more complicated than just using slider/button attachments). I posted about it on this thread:

https://forum.juce.com/t/sending-signal-events-from-audio-to-gui-thread/27792/5

The helpful feedback from @eyalamir in that thread suggested that the thread-safe AND real-time safe way to do the GUI update would be to:

  1. Have the Editor be a AudioProcessorValueTreeState::Listener,
  2. Set an atomic flag in the parameterChanged() callback if the GUI needs updating,
  3. In the Editor use a Timer to poll that flag. If the Editor sees the flag is set, then it handles the repaint from timerCallback(), which already is on the message thread.

I haven’t tried that out myself, but it seems like a good approach.

I’m posting this to solicit further feedback about this approach… since every time I think I’ve figured out thread-safety, I find there’s a new wrinkle I hadn’t considered!