LMMS
Loading...
Searching...
No Matches
juce::ScopedWriteLock Class Reference

#include <juce_ScopedWriteLock.h>

Public Member Functions

 ScopedWriteLock (const ReadWriteLock &lock) noexcept
 ~ScopedWriteLock () noexcept

Private Attributes

const ReadWriteLocklock_

Detailed Description

Automatically locks and unlocks a ReadWriteLock object.

Use one of these as a local variable to control access to a ReadWriteLock.

e.g.

for (;;)
{
const ScopedWriteLock myScopedLock (myLock);
// myLock is now locked
...do some stuff...
// myLock gets unlocked here.
}
Definition juce_ReadWriteLock.h:48
ScopedWriteLock(const ReadWriteLock &lock) noexcept
Definition juce_ScopedWriteLock.h:65
See also
ReadWriteLock, ScopedReadLock

@tags{Core}

Constructor & Destructor Documentation

◆ ScopedWriteLock()

juce::ScopedWriteLock::ScopedWriteLock ( const ReadWriteLock & lock)
inlineexplicitnoexcept

Creates a ScopedWriteLock.

As soon as it is created, this will call ReadWriteLock::enterWrite(), and when the ScopedWriteLock object is deleted, the ReadWriteLock will be unlocked.

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.

◆ ~ScopedWriteLock()

juce::ScopedWriteLock::~ScopedWriteLock ( )
inlinenoexcept

Destructor.

The ReadWriteLock's exitWrite() method will be called 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!

Member Data Documentation

◆ lock_

const ReadWriteLock& juce::ScopedWriteLock::lock_
private

The documentation for this class was generated from the following file: