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

Unified Diff: src/d8.h

Issue 1226143003: d8: Fix some TSAN bugs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: can't use DCHECK for join_called_, unused in NDEBUG builds Created 5 years, 5 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 | src/d8.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.h
diff --git a/src/d8.h b/src/d8.h
index ae9c4f222cee1bbb549a7e3dc9fe0ad08d019686..6c632c9709ca2980e2ec4e9b9240e15e18a8ee00 100644
--- a/src/d8.h
+++ b/src/d8.h
@@ -239,9 +239,19 @@ class Worker {
~Worker();
void StartExecuteInThread(Isolate* isolate, const char* script);
+ // Post a message to the worker's incoming message queue. The worker will
+ // take ownership of the SerializationData.
void PostMessage(SerializationData* data);
+ // Synchronously retrieve messages from the worker's outgoing message queue.
+ // If there is no message in the queue, block until a message is available.
+ // If there are no messages in the queue and the worker is no longer running,
+ // return nullptr.
SerializationData* GetMessage();
+ // Terminate the worker's event loop. Messages from the worker that have been
+ // queued can still be read via GetMessage().
void Terminate();
+ // Terminate and join the thread.
+ void WaitForThread();
private:
class WorkerThread : public base::Thread {
@@ -256,7 +266,11 @@ class Worker {
Worker* worker_;
};
- enum State { IDLE, RUNNING, TERMINATED };
+ enum State {
+ IDLE, // The worker thread hasn't been started yet
+ RUNNING, // The worker thread is running and hasn't been terminated
+ TERMINATED // The worker thread has been terminated and will soon finish
+ };
void ExecuteInThread();
void Cleanup();
@@ -269,6 +283,7 @@ class Worker {
base::Thread* thread_;
char* script_;
base::Atomic32 state_;
+ base::Atomic32 join_called_;
};
#endif // !V8_SHARED
« no previous file with comments | « no previous file | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698