michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef RWLOCK_AUTO_ENTER_H michael@0: #define RWLOCK_AUTO_ENTER_H michael@0: michael@0: #include "prrwlock.h" michael@0: #include "mozilla/Assertions.h" michael@0: michael@0: class RwLockAutoEnterRead michael@0: { michael@0: public: michael@0: RwLockAutoEnterRead(PRRWLock* aRwLock) michael@0: : mRwLock(aRwLock) michael@0: { michael@0: MOZ_ASSERT(mRwLock); michael@0: PR_RWLock_Rlock(mRwLock); michael@0: } michael@0: michael@0: ~RwLockAutoEnterRead() michael@0: { michael@0: PR_RWLock_Unlock(mRwLock); michael@0: } michael@0: michael@0: protected: michael@0: PRRWLock* mRwLock; michael@0: }; michael@0: michael@0: class RwLockAutoEnterWrite michael@0: { michael@0: public: michael@0: RwLockAutoEnterWrite(PRRWLock* aRwLock) michael@0: : mRwLock(aRwLock) michael@0: { michael@0: MOZ_ASSERT(mRwLock); michael@0: PR_RWLock_Wlock(mRwLock); michael@0: } michael@0: michael@0: ~RwLockAutoEnterWrite() michael@0: { michael@0: PR_RWLock_Unlock(mRwLock); michael@0: } michael@0: michael@0: protected: michael@0: PRRWLock* mRwLock; michael@0: }; michael@0: michael@0: #endif // RWLOCK_AUTO_ENTER_H