AudioProcessorParameter and thread safety


It's more a theoretic question as I never had any threading problems here, but...

Though you mention at getValue() this: "It's also likely to be called by non-UI threads, so the code in here should be thread-aware." but in the the derived classes like "AudioParameterFloat" Juce uses simple floats to store the value.

Maybe I'm wrong but as I know floats are not atomic, so even a store or load can cause problems if it's not aligned well in memory.

Shouldn't be those VALUE variables atomic types?

thx for your answer in advance!


In theory, yes! In practice, they will be aligned and the way these classes are used makes it very unlikely that the compiler would optimise it away, but you're right, we really should have wrapped them as atomics..


thanks Jules for the quick reply!