Non-re-entrant mutex

Hi, for a non-rentrant mutex should I just use SpinLock instead of CriticalSection or is there something else in Juce for this purpose?

Thx

You could use std::mutex, that’s non-reentrant.

1 Like

Thx, I was more looking for Juce locks rather than from the std library as I didn’t really want to mix Juce and std library. thx

You could use juce::SpinLock. Cause it does not set the memory order for read & write and tries the compareAndSetBool each time, it is kind of a sub-optimal solution. BTW I only uses SpinLock if I want one thread to be non-blocking (which uses try-lock). Otherwise, I will also choose std::mutex.

1 Like