#include <juce_ScopedReadLock.h>
Automatically locks and unlocks a ReadWriteLock object.
Use one of these as a local variable to control access to a ReadWriteLock.
e.g.
for (;;)
{
if (myScopedTryLock.isLocked())
{
...do some stuff...
}
else
{
..our attempt at locking failed because
a write lock
has already been issued..
}
}
uint8_t a
Definition Spc_Cpu.h:141
Definition juce_ReadWriteLock.h:48
ScopedTryReadLock(ReadWriteLock &lockIn)
Definition juce_ScopedReadLock.h:131
bool has(T &t, Z &z)
Definition ports.cpp:334
- See also
- ReadWriteLock, ScopedTryWriteLock
@tags{Core}
◆ ScopedTryReadLock() [1/2]
| juce::ScopedTryReadLock::ScopedTryReadLock |
( |
ReadWriteLock & | lockIn | ) |
|
|
inlineexplicit |
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.
◆ ScopedTryReadLock() [2/2]
| juce::ScopedTryReadLock::ScopedTryReadLock |
( |
ReadWriteLock & | lockIn, |
|
|
bool | acquireLockOnInitialisation ) |
|
inlinenoexcept |
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.
◆ ~ScopedTryReadLock()
| juce::ScopedTryReadLock::~ScopedTryReadLock |
( |
| ) |
|
|
inlinenoexcept |
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!
◆ isLocked()
| bool juce::ScopedTryReadLock::isLocked |
( |
| ) |
const |
|
inlinenoexcept |
Returns true if the mutex was successfully locked.
◆ retryLock()
| bool juce::ScopedTryReadLock::retryLock |
( |
| ) |
|
|
inlinenoexcept |
Retry gaining the lock by calling tryEnter on the underlying lock.
◆ lock
◆ lockWasSuccessful
| bool juce::ScopedTryReadLock::lockWasSuccessful |
|
private |
The documentation for this class was generated from the following file:
- /home/runner/work/lmms-fork/lmms-fork/plugins/CarlaBase/carla/source/modules/juce_core/threads/juce_ScopedReadLock.h