mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-01 04:47:31 +09:00
Add infallibleInit method to ThreadLocal and AssertOwns methods to Mutex
This commit is contained in:
parent
498b121c86
commit
32e0f7f621
2 changed files with 26 additions and 0 deletions
|
|
@ -132,6 +132,8 @@ public:
|
||||||
|
|
||||||
MOZ_MUST_USE inline bool init();
|
MOZ_MUST_USE inline bool init();
|
||||||
|
|
||||||
|
inline void infallibleInit();
|
||||||
|
|
||||||
inline T get() const;
|
inline T get() const;
|
||||||
|
|
||||||
inline void set(const T aValue);
|
inline void set(const T aValue);
|
||||||
|
|
@ -171,6 +173,15 @@ ThreadLocal<T>::init()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline void
|
||||||
|
ThreadLocal<T>::infallibleInit()
|
||||||
|
{
|
||||||
|
if (!init()) {
|
||||||
|
MOZ_CRASH("unable to initialize ThreadLocal");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T
|
inline T
|
||||||
ThreadLocal<T>::get() const
|
ThreadLocal<T>::get() const
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,21 @@ public:
|
||||||
mLock->Unlock();
|
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:
|
private:
|
||||||
BaseAutoLock();
|
BaseAutoLock();
|
||||||
BaseAutoLock(BaseAutoLock&);
|
BaseAutoLock(BaseAutoLock&);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue