mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1207753 - ThrottledEventQueue thread-safety annotations r=nika
Differential Revision: https://phabricator.services.mozilla.com/D142018
This commit is contained in:
parent
030cb502bf
commit
72c8c85448
@ -94,33 +94,33 @@ class ThrottledEventQueue::Inner final : public nsISupports {
|
||||
#endif
|
||||
};
|
||||
|
||||
mutable Mutex mMutex MOZ_UNANNOTATED;
|
||||
mutable CondVar mIdleCondVar;
|
||||
mutable Mutex mMutex;
|
||||
mutable CondVar mIdleCondVar GUARDED_BY(mMutex);
|
||||
|
||||
// As-of-yet unexecuted runnables queued on this ThrottledEventQueue.
|
||||
//
|
||||
// Used from any thread; protected by mMutex. Signals mIdleCondVar when
|
||||
// emptied.
|
||||
EventQueueSized<64> mEventQueue;
|
||||
EventQueueSized<64> mEventQueue GUARDED_BY(mMutex);
|
||||
|
||||
// The event target we dispatch our events (actually, just our Executor) to.
|
||||
//
|
||||
// Written only during construction. Readable by any thread without locking.
|
||||
nsCOMPtr<nsISerialEventTarget> mBaseTarget;
|
||||
const nsCOMPtr<nsISerialEventTarget> mBaseTarget;
|
||||
|
||||
// The Executor that we dispatch to mBaseTarget to draw runnables from our
|
||||
// queue. mExecutor->mInner points to this Inner, forming a reference loop.
|
||||
//
|
||||
// Used from any thread; protected by mMutex.
|
||||
nsCOMPtr<nsIRunnable> mExecutor;
|
||||
nsCOMPtr<nsIRunnable> mExecutor GUARDED_BY(mMutex);
|
||||
|
||||
const char* mName;
|
||||
const char* const mName;
|
||||
|
||||
const uint32_t mPriority;
|
||||
|
||||
// True if this queue is currently paused.
|
||||
// Used from any thread; protected by mMutex.
|
||||
bool mIsPaused;
|
||||
bool mIsPaused GUARDED_BY(mMutex);
|
||||
|
||||
explicit Inner(nsISerialEventTarget* aBaseTarget, const char* aName,
|
||||
uint32_t aPriority)
|
||||
@ -154,7 +154,7 @@ class ThrottledEventQueue::Inner final : public nsISupports {
|
||||
|
||||
// Make sure an executor has been queued on our base target. If we already
|
||||
// have one, do nothing; otherwise, create and dispatch it.
|
||||
nsresult EnsureExecutor(MutexAutoLock& lock) {
|
||||
nsresult EnsureExecutor(MutexAutoLock& lock) REQUIRES(mMutex) {
|
||||
if (mExecutor) return NS_OK;
|
||||
|
||||
// Note, this creates a ref cycle keeping the inner alive
|
||||
@ -308,7 +308,9 @@ class ThrottledEventQueue::Inner final : public nsISupports {
|
||||
return IsPaused(lock);
|
||||
}
|
||||
|
||||
bool IsPaused(const MutexAutoLock& aProofOfLock) const { return mIsPaused; }
|
||||
bool IsPaused(const MutexAutoLock& aProofOfLock) const REQUIRES(mMutex) {
|
||||
return mIsPaused;
|
||||
}
|
||||
|
||||
nsresult SetIsPaused(bool aIsPaused) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
Loading…
Reference in New Issue
Block a user