Automatically locks and unlocks a ReadWriteLock object. More...
#include <juce_ScopedReadLock.h>
Public Member Functions | |
ScopedTryReadLock (ReadWriteLock &lockIn) | |
Creates a ScopedTryReadLock and calls ReadWriteLock::tryEnterRead() as soon as it is created. | |
ScopedTryReadLock (ReadWriteLock &lockIn, bool acquireLockOnInitialisation) noexcept | |
Creates a ScopedTryReadLock. | |
~ScopedTryReadLock () noexcept | |
Destructor. | |
bool | isLocked () const noexcept |
Returns true if the mutex was successfully locked. | |
bool | retryLock () noexcept |
Retry gaining the lock by calling tryEnter on the underlying lock. | |
Automatically locks and unlocks a ReadWriteLock object.
Use one of these as a local variable to control access to a ReadWriteLock.
e.g.
|
explicit |
Creates a ScopedTryReadLock and calls ReadWriteLock::tryEnterRead() as soon as it is created.
When the ScopedTryReadLock object is destructed, the ReadWriteLock will be unlocked (if it was successfully acquired).
Make sure this object is created and destructed 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.
|
noexcept |
Creates a ScopedTryReadLock.
If acquireLockOnInitialisation is true then as soon as it is created, this will call ReadWriteLock::tryEnterRead(), and when the ScopedTryReadLock object is destructed, the ReadWriteLock will be unlocked (if it was successfully acquired).
Make sure this object is created and destructed 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.
|
noexcept |
Destructor.
The ReadWriteLock's exitRead() method will be called when the destructor is called.
Make sure this object is created and destructed by the same thread, otherwise there are no guarantees what will happen!
|
noexcept |
Returns true if the mutex was successfully locked.
|
noexcept |
Retry gaining the lock by calling tryEnter on the underlying lock.