DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::SpinLock::ScopedTryLock Class Reference

RAII wrapper that tries to acquire the lock without blocking. More...

#include <SpinLock.h>

Public Member Functions

 ScopedTryLock (SpinLock &spinLock) noexcept
 Constructs the guard and attempts a single lock acquisition.
 
 ~ScopedTryLock () noexcept
 Destructs the guard and releases the lock ONLY if it was successfully acquired.
 
bool isLocked () const noexcept
 Queries whether the lock acquisition was successful.
 
 ScopedTryLock (const ScopedTryLock &)=delete
 
ScopedTryLockoperator= (const ScopedTryLock &)=delete
 

Detailed Description

RAII wrapper that tries to acquire the lock without blocking.

Check isLocked() before accessing the protected resource. Essential for reading shared data safely within the real-time audio thread.

Definition at line 161 of file SpinLock.h.

Constructor & Destructor Documentation

◆ ScopedTryLock() [1/2]

dspark::SpinLock::ScopedTryLock::ScopedTryLock ( SpinLock spinLock)
inlineexplicitnoexcept

Constructs the guard and attempts a single lock acquisition.

Parameters
spinLockThe SpinLock to attempt to manage.

Definition at line 168 of file SpinLock.h.

◆ ~ScopedTryLock()

dspark::SpinLock::ScopedTryLock::~ScopedTryLock ( )
inlinenoexcept

Destructs the guard and releases the lock ONLY if it was successfully acquired.

Definition at line 172 of file SpinLock.h.

◆ ScopedTryLock() [2/2]

dspark::SpinLock::ScopedTryLock::ScopedTryLock ( const ScopedTryLock )
delete

Member Function Documentation

◆ isLocked()

bool dspark::SpinLock::ScopedTryLock::isLocked ( ) const
inlinenoexcept

Queries whether the lock acquisition was successful.

Returns
true if the lock is held by this guard, false otherwise.

Definition at line 178 of file SpinLock.h.

◆ operator=()

ScopedTryLock & dspark::SpinLock::ScopedTryLock::operator= ( const ScopedTryLock )
delete

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