ScopedLock vs std::lock_guard

Hi folks!

What are you using in your code: ScopedLock or std::lock_guard?
Is there any reason to prefer one instead of the other.
I noticed that with time i use more stuff from std:: and less from juce:: namespace.

I tend to use std::mutex/std::scoped_lock over juce::CriticalSection/juce::ScopedLock these days.

At the end of the day their function is pretty much identical so it mostly comes down to preference of JUCE over STL.

1 Like

juce::CriticalSection is a recursive mutex: std::recursive_mutex which behaves differently to std::mutex.

6 Likes