Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: third_party/WebKit/Source/core/workers/WorkerThread.h

Issue 2268183005: Worker: Refine state management of WorkerThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove TODO comment to avoid patch confliction Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/workers/WorkerThread.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/workers/WorkerThread.h
diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.h b/third_party/WebKit/Source/core/workers/WorkerThread.h
index c57cb9117d3972875ac8086a9a3853e63fa1e955..752ff21cd5d89114e9063ec25611306eaa1852b7 100644
--- a/third_party/WebKit/Source/core/workers/WorkerThread.h
+++ b/third_party/WebKit/Source/core/workers/WorkerThread.h
@@ -205,13 +205,22 @@ private:
ExitCode getExitCodeForTesting();
// Accessed only on the main thread.
- bool m_started = false;
+ bool m_requestedToStart = false;
// Set on the main thread and checked on both the main and worker threads.
- bool m_terminated = false;
-
- // Set on the worker thread and checked on both the main and worker threads.
- bool m_readyToShutdown = false;
+ bool m_requestedToTerminate = false;
+
+ // Represents the state of this worker thread. A caller may need to acquire
+ // a lock |m_threadStateMutex| before accessing this:
+ // - Only the worker thread can set this with the lock.
+ // - The worker thread can read this without the lock.
+ // - The main thread can read this with the lock.
+ enum class ThreadState {
+ NotStarted,
+ Running,
+ ReadyToShutdown,
+ };
+ ThreadState m_threadState = ThreadState::NotStarted;
// Accessed only on the worker thread.
bool m_pausedInDebugger = false;
@@ -229,8 +238,8 @@ private:
RefPtr<WorkerLoaderProxy> m_workerLoaderProxy;
WorkerReportingProxy& m_workerReportingProxy;
- // This lock protects |m_globalScope|, |m_terminated|, |m_readyToShutdown|,
- // |m_runningDebuggerTask|, |m_exitCode| and |m_microtaskRunner|.
+ // This lock protects |m_globalScope|, |m_requestedToTerminate|,
+ // |m_threadState|, |m_runningDebuggerTask| and |m_exitCode|.
Mutex m_threadStateMutex;
Persistent<ConsoleMessageStorage> m_consoleMessageStorage;
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/workers/WorkerThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698