Add infallibleInit method to ThreadLocal and AssertOwns methods to Mutex

This commit is contained in:
ownedbywuigi 2026-03-30 00:30:51 +01:00
commit 32e0f7f621
2 changed files with 26 additions and 0 deletions

View file

@ -172,6 +172,21 @@ public:
mLock->Unlock();
}
// Assert that the current thread owns the lock right now.
void AssertOwns() const
{
mLock->AssertCurrentThreadOwns();
}
// Assert that aLock is the lock passed to the constructor and that the
// current thread owns it. Pointer equality alone is not sufficient because
// lock ownership may be temporarily released with BaseAutoUnlock.
void AssertOwns(const T& aLock) const
{
MOZ_ASSERT(&aLock == mLock);
AssertOwns();
}
private:
BaseAutoLock();
BaseAutoLock(BaseAutoLock&);