OpenShot Audio Library | OpenShotAudio 0.3.2
|
#include <juce_ScopedLock.h>
Public Member Functions | |
GenericScopedTryLock (const LockType &lock, bool acquireLockOnInitialisation=true) noexcept | |
~GenericScopedTryLock () noexcept | |
bool | isLocked () const noexcept |
bool | retryLock () const noexcept |
Automatically locks and unlocks a mutex object.
Use one of these as a local variable to provide RAII-based locking of a mutex.
The templated class could be a CriticalSection, SpinLock, or anything else that provides enter() and exit() methods.
e.g.
Definition at line 197 of file juce_ScopedLock.h.
|
inlineexplicitnoexcept |
Creates a GenericScopedTryLock.
If acquireLockOnInitialisation is true then as soon as this ScopedTryLock is created, it will attempt to acquire the lock with tryEnter.
You can retry acquiring the lock by calling retryLock.
When GenericScopedTryLock is deleted, the lock will be released (if the lock was successfully acquired).
Make sure this object is created and deleted by the same thread, otherwise there are no guarantees what will happen! Best just to use it as a local stack object, rather than creating one with the new() operator.
Definition at line 217 of file juce_ScopedLock.h.
|
inlinenoexcept |
Destructor.
The mutex will be unlocked (if it had been successfully locked) when the destructor is called.
Make sure this object is created and deleted by the same thread, otherwise there are no guarantees what will happen!
Definition at line 228 of file juce_ScopedLock.h.
|
inlinenoexcept |
Returns true if the mutex was successfully locked.
Definition at line 231 of file juce_ScopedLock.h.
|
inlinenoexcept |
Retry gaining the lock by calling tryEnter on the underlying lock.
Definition at line 234 of file juce_ScopedLock.h.