24 #ifndef PXR_BASE_TF_BIG_RW_MUTEX_H
25 #define PXR_BASE_TF_BIG_RW_MUTEX_H
153 _acqState = _mutex->_AcquireRead(_GetSeed());
160 _mutex->_AcquireWrite();
179 void _ReleaseRead() {
181 _mutex->_ReleaseRead(_acqState);
185 void _ReleaseWrite() {
187 _mutex->_ReleaseWrite();
193 inline int _GetSeed()
const {
194 return static_cast<int>(
195 static_cast<unsigned>(
TfHash()(
this)) >> 8);
207 inline int _AcquireRead(
int seed) {
211 !_states[stateIndex].mutex.TryAcquireRead()) {
212 _AcquireReadContended(stateIndex);
218 TF_API void _AcquireReadContended(
int stateIndex);
220 void _ReleaseRead(
int stateIndex) {
221 _states[stateIndex].mutex.ReleaseRead();
224 TF_API void _AcquireWrite();
225 TF_API void _ReleaseWrite();
231 char _unused_padding[
235 std::unique_ptr<_LockState []> _states;
236 std::atomic<bool> _writerActive;
242 #endif // PXR_BASE_TF_BIG_RW_MUTEX_H
static constexpr unsigned NumStates
TF_API TfBigRWMutex()
Construct a mutex, initially unlocked.
void Acquire(TfBigRWMutex &m, bool write=true)
static constexpr int NotAcquired
static constexpr int NotLocked
ScopedLock(TfBigRWMutex &m, bool write=true)
static constexpr int WriteLocked
#define ARCH_CACHE_LINE_SIZE
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
void Acquire(bool write=true)
ScopedLock()
Construct a scoped lock not associated with a mutex.
static constexpr int WriteAcquired