JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
juce::ReadWriteLock Class Reference

A critical section that allows multiple simultaneous readers. More...

#include "juce_ReadWriteLock.h"

Public Member Functions

 ReadWriteLock () noexcept
 Creates a ReadWriteLock object.
 
 ~ReadWriteLock () noexcept
 Destructor.
 
void enterRead () const noexcept
 Locks this object for reading.
 
bool tryEnterRead () const noexcept
 Tries to lock this object for reading.
 
void exitRead () const noexcept
 Releases the read-lock.
 
void enterWrite () const noexcept
 Locks this object for writing.
 
bool tryEnterWrite () const noexcept
 Tries to lock this object for writing.
 
void exitWrite () const noexcept
 Releases the write-lock.
 

Detailed Description

A critical section that allows multiple simultaneous readers.

Features of this type of lock are:

See also
ScopedReadLock, ScopedWriteLock, CriticalSection

@tags{Core}

Definition at line 47 of file juce_ReadWriteLock.h.

Constructor & Destructor Documentation

◆ ReadWriteLock()

juce::ReadWriteLock::ReadWriteLock ( )
noexcept

Creates a ReadWriteLock object.

Definition at line 26 of file juce_ReadWriteLock.cpp.

◆ ~ReadWriteLock()

juce::ReadWriteLock::~ReadWriteLock ( )
noexcept

Destructor.

If the object is deleted whilst locked, any subsequent behaviour is undefined.

Definition at line 31 of file juce_ReadWriteLock.cpp.

Member Function Documentation

◆ enterRead()

void juce::ReadWriteLock::enterRead ( ) const
noexcept

Locks this object for reading.

Multiple threads can simultaneously lock the object for reading, but if another thread has it locked for writing, then this will block until it releases the lock.

See also
exitRead, ScopedReadLock

Definition at line 38 of file juce_ReadWriteLock.cpp.

◆ enterWrite()

void juce::ReadWriteLock::enterWrite ( ) const
noexcept

Locks this object for writing.

This will block until any other threads that have it locked for reading or writing have released their lock.

See also
exitWrite, ScopedWriteLock

Definition at line 96 of file juce_ReadWriteLock.cpp.

◆ exitRead()

void juce::ReadWriteLock::exitRead ( ) const
noexcept

Releases the read-lock.

If the caller thread hasn't got the lock, this can have unpredictable results.

If the enterRead() method has been called multiple times by the thread, each call must be matched by a call to exitRead() before other threads will be allowed to take over the lock.

See also
enterRead, ScopedReadLock

Definition at line 69 of file juce_ReadWriteLock.cpp.

◆ exitWrite()

void juce::ReadWriteLock::exitWrite ( ) const
noexcept

Releases the write-lock.

If the caller thread hasn't got the lock, this can have unpredictable results.

If the enterWrite() method has been called multiple times by the thread, each call must be matched by a call to exit() before other threads will be allowed to take over the lock.

See also
enterWrite, ScopedWriteLock

Definition at line 131 of file juce_ReadWriteLock.cpp.

◆ tryEnterRead()

bool juce::ReadWriteLock::tryEnterRead ( ) const
noexcept

Tries to lock this object for reading.

Multiple threads can simultaneously lock the object for reading, but if another thread has it locked for writing, then this will fail and return false.

Returns
true if the lock is successfully gained.
See also
exitRead, ScopedTryReadLock

Definition at line 44 of file juce_ReadWriteLock.cpp.

◆ tryEnterWrite()

bool juce::ReadWriteLock::tryEnterWrite ( ) const
noexcept

Tries to lock this object for writing.

This is like enterWrite(), but doesn't block - it returns true if it manages to obtain the lock.

Returns
true if the lock is successfully gained.
See also
enterWrite, ScopedTryWriteLock

Definition at line 111 of file juce_ReadWriteLock.cpp.


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