TfBigRWMutex::ScopedLock Struct Reference

Scoped lock utility class. More...

Public Member Functions

 ScopedLock (TfBigRWMutex &m, bool write=true)
 Construct a scoped lock for mutex m and acquire either a read or a write lock depending on write. More...
 
 ScopedLock ()
 Construct a scoped lock not associated with a mutex. More...
 
 ~ScopedLock ()
 If this scoped lock is acquired for either read or write, Release() it. More...
 
void Acquire (TfBigRWMutex &m, bool write=true)
 If the current scoped lock is acquired, Release() it, then associate this lock with m and acquire either a read or a write lock, depending on write. More...
 
void Acquire (bool write=true)
 Acquire either a read or write lock on this lock's associated mutex depending on write. More...
 
void Release ()
 Release the currently required lock on the associated mutex. More...
 
void AcquireRead ()
 Acquire a read lock on this lock's associated mutex. More...
 
void AcquireWrite ()
 Acquire a write lock on this lock's associated mutex. More...
 
bool UpgradeToWriter ()
 Change this lock's acquisition state from a read lock to a write lock. More...
 

Static Public Attributes

static constexpr int NotAcquired = -1
 
static constexpr int WriteAcquired = -2
 

Detailed Description

Scoped lock utility class.

API modeled after tbb::spin_rw_mutex::scoped_lock.

Definition at line 86 of file bigRWMutex.h.

Constructor & Destructor Documentation

◆ ScopedLock() [1/2]

ScopedLock ( TfBigRWMutex m,
bool  write = true 
)
inlineexplicit

Construct a scoped lock for mutex m and acquire either a read or a write lock depending on write.

Definition at line 96 of file bigRWMutex.h.

◆ ScopedLock() [2/2]

ScopedLock ( )
inline

Construct a scoped lock not associated with a mutex.

Definition at line 103 of file bigRWMutex.h.

◆ ~ScopedLock()

~ScopedLock ( )
inline

If this scoped lock is acquired for either read or write, Release() it.

Definition at line 107 of file bigRWMutex.h.

Member Function Documentation

◆ Acquire() [1/2]

void Acquire ( TfBigRWMutex m,
bool  write = true 
)
inline

If the current scoped lock is acquired, Release() it, then associate this lock with m and acquire either a read or a write lock, depending on write.

Definition at line 114 of file bigRWMutex.h.

◆ Acquire() [2/2]

void Acquire ( bool  write = true)
inline

Acquire either a read or write lock on this lock's associated mutex depending on write.

This lock must be associated with a mutex (typically by construction or by a call to Acquire() that takes a mutex). This lock must not already be acquired when calling Acquire().

Definition at line 125 of file bigRWMutex.h.

◆ AcquireRead()

void AcquireRead ( )
inline

Acquire a read lock on this lock's associated mutex.

This lock must not already be acquired when calling AcquireRead().

Definition at line 151 of file bigRWMutex.h.

◆ AcquireWrite()

void AcquireWrite ( )
inline

Acquire a write lock on this lock's associated mutex.

This lock must not already be acquired when calling AcquireWrite().

Definition at line 158 of file bigRWMutex.h.

◆ Release()

void Release ( )
inline

Release the currently required lock on the associated mutex.

If this lock is not currently acquired, silently do nothing.

Definition at line 136 of file bigRWMutex.h.

◆ UpgradeToWriter()

bool UpgradeToWriter ( )
inline

Change this lock's acquisition state from a read lock to a write lock.

This lock must already be acquired for reading. For consistency with tbb, this function returns a bool indicating whether the upgrade was done atomically, without releasing the read-lock. However the current implementation always releases the read lock so this function always returns false.

Definition at line 170 of file bigRWMutex.h.


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