Interaction of GUI, data model, and audio thread process

Hi all. I have an app that functions a lot like a standalone audio plugin. There is a parameter class passed by reference to both the GUI class and the algorithm implementation class. The algorithm runs in the audio thread and accesses the private parameters directly as a friend class. The GUI gets and sets parameters using accessor functions. I haven’t run into any threading problems yet, but should I be using some kind of locking in the accessors (or elsewhere)? If so, what would be the easiest way of doing this?

easiest way:

  • use CriticalSections for reading and writing, to protect the integrity (but be careful because of performance intrusion)
    keep locks as shot as possible, no memory allocation inside the lock (on any! thread)
  • use Atomic Variables

more sophisticated:
use lock-free fifos between the threads, for communication (Vinnie posted something therefor)

The DSPFilters application has an example of a working fifo - see ThreadQueue.cpp and ThreadQueue.h

I am new to JUCE. May I ask you how you separated the GUI and audio processing to different threads in a standalone app?