HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfBigRWMutex::ScopedLock Struct Reference

#include <bigRWMutex.h>

Public Member Functions

 ScopedLock (TfBigRWMutex &m, bool write=true)
 
 ScopedLock ()
 Construct a scoped lock not associated with a mutex. More...
 
 ~ScopedLock ()
 
void Acquire (TfBigRWMutex &m, bool write=true)
 
void Acquire (bool write=true)
 
void Release ()
 
void AcquireRead ()
 
void AcquireWrite ()
 
bool UpgradeToWriter ()
 

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

TfBigRWMutex::ScopedLock::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.

TfBigRWMutex::ScopedLock::ScopedLock ( )
inline

Construct a scoped lock not associated with a mutex.

Definition at line 103 of file bigRWMutex.h.

TfBigRWMutex::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

void TfBigRWMutex::ScopedLock::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.

void TfBigRWMutex::ScopedLock::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.

void TfBigRWMutex::ScopedLock::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.

void TfBigRWMutex::ScopedLock::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.

void TfBigRWMutex::ScopedLock::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.

bool TfBigRWMutex::ScopedLock::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.

Member Data Documentation

constexpr int TfBigRWMutex::ScopedLock::NotAcquired = -1
static

Definition at line 91 of file bigRWMutex.h.

constexpr int TfBigRWMutex::ScopedLock::WriteAcquired = -2
static

Definition at line 92 of file bigRWMutex.h.


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