JUCE: ScopedWriteLock Class Reference

JUCE

- Main Page
- Related Pages
- Topics
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Loading...
Searching...
No Matches
Public Member Functions | List of all members
ScopedWriteLock Class Reference
juce_core » threads

Automatically locks and unlocks a ReadWriteLock object. More...

`#include <juce_ScopedWriteLock.h>`

## Public Member Functions
| ScopedWriteLock (const ReadWriteLock &lock) noexcept
| Creates a ScopedWriteLock.
| ~ScopedWriteLock () noexcept
| Destructor.

## 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.

ReadWriteLock myLock;
for (;;)
{
const ScopedWriteLock myScopedLock (myLock);
// myLock is now locked
...do some stuff...
// myLock gets unlocked here.
}
ReadWriteLock
A critical section that allows multiple simultaneous readers.
Definition juce_ReadWriteLock.h:49
ScopedWriteLock
Automatically locks and unlocks a ReadWriteLock object.
Definition juce_ScopedWriteLock.h:53

See also
  ReadWriteLock, ScopedReadLock

## Constructor & Destructor Documentation

## ◆ ScopedWriteLock()

ScopedWriteLock::ScopedWriteLock | ( | const ReadWriteLock & | lock | ) |
| explicitnoexcept

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()

ScopedWriteLock::~ScopedWriteLock | ( |  | ) |
| noexcept

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!

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

- juce_ScopedWriteLock.h