7 #ifndef PXR_BASE_TF_BIG_RW_MUTEX_H
8 #define PXR_BASE_TF_BIG_RW_MUTEX_H
136 _acqState = _mutex->_AcquireRead(_GetSeed());
143 _mutex->_AcquireWrite();
162 void _ReleaseRead() {
164 _mutex->_ReleaseRead(_acqState);
168 void _ReleaseWrite() {
170 _mutex->_ReleaseWrite();
176 inline int _GetSeed()
const {
177 return static_cast<int>(
178 static_cast<unsigned>(
TfHash()(
this)) >> 8);
190 inline int _AcquireRead(
int seed) {
194 !_states[stateIndex].mutex.TryAcquireRead()) {
195 _AcquireReadContended(stateIndex);
201 TF_API void _AcquireReadContended(
int stateIndex);
203 void _ReleaseRead(
int stateIndex) {
204 _states[stateIndex].mutex.ReleaseRead();
207 TF_API void _AcquireWrite();
208 TF_API void _ReleaseWrite();
214 char _unused_padding[
218 std::unique_ptr<_LockState []> _states;
219 std::atomic<bool> _writerActive;
225 #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