Loading...
Searching...
No Matches
juce::GenericScopedLock< LockType > Class Template Reference

## Detailed Description

template<class LockType>
class juce::GenericScopedLock< LockType >

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.

CriticalSection myCriticalSection;
for (;;)
{
const GenericScopedLock<CriticalSection> myScopedLock (myCriticalSection);
// myCriticalSection is now locked
...do some stuff...
// myCriticalSection gets unlocked here
}
juce::CriticalSection
A re-entrant mutex.
Definition juce_CriticalSection.h:55
juce::GenericScopedLock::GenericScopedLock
GenericScopedLock(const LockType &lock) noexcept
Creates a GenericScopedLock.
Definition juce_ScopedLock.h:79

See also
  GenericScopedUnlock, CriticalSection, SpinLock, ScopedLock, ScopedUnlock

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

- juce_core/threads/juce_ScopedLock.h

## Public Member Functions

| GenericScopedLock (const LockType &lock) noexcept
| Creates a GenericScopedLock.
| ~GenericScopedLock () noexcept
| Destructor.

## Constructors and Destructors

## GenericScopedLock()

template<class LockType>

juce::GenericScopedLock< LockType >::GenericScopedLock | ( | const LockType & | lock | ) |

inline explicit noexcept

Creates a GenericScopedLock.

As soon as it is created, this will acquire the lock, and when the GenericScopedLock object is deleted, the lock will be released.

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.

## ~GenericScopedLock()

template<class LockType>

juce::GenericScopedLock< LockType >::~GenericScopedLock | ( |  | ) |

inline noexcept

Destructor.

The lock will be released 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!

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited