JUCE
Loading...
Searching...
No Matches
Public Member Functions | List of all members
GenericScopedUnlock< LockType > Class Template Reference

Automatically unlocks and re-locks a mutex object. More...

Public Member Functions

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

Detailed Description

template<class LockType>
class GenericScopedUnlock< LockType >

Automatically unlocks and re-locks a mutex object.

This is the reverse of a GenericScopedLock object - instead of locking the mutex for the lifetime of this object, it unlocks it.

Make sure you don't try to unlock mutexes that aren't actually locked!

e.g.

for (;;)
{
// myCriticalSection is now locked
... do some stuff with it locked ..
while (xyz)
{
... do some stuff with it locked ..
// myCriticalSection is now unlocked for the remainder of this block,
// and re-locked at the end.
...do some stuff with it unlocked ...
}
// myCriticalSection gets unlocked here.
}
A re-entrant mutex.
Definition juce_CriticalSection.h:56
Helper class for using linear interpolation between a begin and an end value.
Definition juce_StaticAnimationLimits.h:75
See also
GenericScopedLock, CriticalSection, ScopedLock, ScopedUnlock

Constructor & Destructor Documentation

◆ GenericScopedUnlock()

Creates a GenericScopedUnlock.

As soon as it is created, this will unlock the CriticalSection, and when the ScopedLock object is deleted, the CriticalSection will be re-locked.

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.

◆ ~GenericScopedUnlock()

Destructor.

The CriticalSection will be unlocked 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!