Skip to content

Commit 2f853ca

Browse files
committed
Bug 1738106 - Part 1: TaskQueue thread safety annotations, r=xpcom-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D142602
1 parent 2b825a7 commit 2f853ca

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

xpcom/threads/TaskQueue.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,23 @@ class TaskQueue : public AbstractThread, public nsIDirectTaskDispatcher {
140140
}
141141
}
142142

143-
nsCOMPtr<nsIEventTarget> mTarget;
143+
nsCOMPtr<nsIEventTarget> mTarget GUARDED_BY(mQueueMonitor);
144144

145145
// Monitor that protects the queue, mIsRunning, mIsShutdown and
146146
// mShutdownTasks;
147-
Monitor mQueueMonitor MOZ_UNANNOTATED;
147+
Monitor mQueueMonitor;
148148

149149
typedef struct TaskStruct {
150150
nsCOMPtr<nsIRunnable> event;
151151
uint32_t flags;
152152
} TaskStruct;
153153

154154
// Queue of tasks to run.
155-
Queue<TaskStruct> mTasks;
155+
Queue<TaskStruct> mTasks GUARDED_BY(mQueueMonitor);
156156

157157
// List of tasks to run during shutdown.
158-
nsTArray<nsCOMPtr<nsITargetShutdownTask>> mShutdownTasks;
158+
nsTArray<nsCOMPtr<nsITargetShutdownTask>> mShutdownTasks
159+
GUARDED_BY(mQueueMonitor);
159160

160161
// The thread currently running the task queue. We store a reference
161162
// to this so that IsCurrentThreadIn() can tell if the current thread
@@ -207,11 +208,11 @@ class TaskQueue : public AbstractThread, public nsIDirectTaskDispatcher {
207208

208209
// True if we've dispatched an event to the target to execute events from
209210
// the queue.
210-
bool mIsRunning;
211+
bool mIsRunning GUARDED_BY(mQueueMonitor);
211212

212213
// True if we've started our shutdown process.
213-
bool mIsShutdown;
214-
MozPromiseHolder<ShutdownPromise> mShutdownPromise;
214+
bool mIsShutdown GUARDED_BY(mQueueMonitor);
215+
MozPromiseHolder<ShutdownPromise> mShutdownPromise GUARDED_BY(mQueueMonitor);
215216

216217
// The name of this TaskQueue. Useful when debugging dispatch failures.
217218
const char* const mName;

0 commit comments

Comments
 (0)