ScopedWriteLock Class Reference

#include <spinlock.h>

Detailed Description

The ScopedWriteLock class acquires a write lock to the specified mutex upon creation and releases this upon destruction (usually at the end of a code block. This simplifies cases where your code contains many return statements where you'd otherwise have to manually unlock before returning. Only use ScopedWriteLock for a short block of your code. Do not use ScopedWriteLock mindlessly at the beginning of a function! This will block all other threads for the whole runtime of the function which usually is much longer that required.

THREADSAFE.

Public Member Functions

 ScopedWriteLock (RWSpinlock &lock)
 
 ScopedWriteLock (ScopedWriteLock &&src)
 
 ~ScopedWriteLock ()
 

Private Member Functions

 MAXON_DISALLOW_COPY_AND_ASSIGN (ScopedWriteLock)
 

Private Attributes

RWSpinlock_lock
 

Constructor & Destructor Documentation

◆ ScopedWriteLock() [1/2]

ScopedWriteLock ( RWSpinlock lock)
explicit

Acquires write access to the specified lock (and releases it upon destruction).

Parameters
[in]lockThe lock to be acquired.

◆ ScopedWriteLock() [2/2]

Move constructor.

◆ ~ScopedWriteLock()

Releases the lock on destruction.

Member Function Documentation

◆ MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( ScopedWriteLock  )
private

Member Data Documentation

◆ _lock

RWSpinlock* _lock
private