Short question, does it take a predictable amount of time for a try lock call on some mutex to return? I’m lacking a bit of understanding of the level at which mutexes are managed, will this cause some system call with unpredictable return time depending on the system load or will this return immediately in any case as this is no real system call?
Background: I have some buffers which are filled with audio samples that might get reallocated because of external events at any time. I simply want to ignore samples that are coming in while reallocating so I’m wrapping the access in a try lock on the audio thread side and use a normal lock on the side that initiates the reallocation from another thread. This works like a charm on my computer but I just want to be sure if this should be safe in every case?