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

Unified Diff: src/d8.h

Issue 1255563002: [d8 Workers] Fix bug creating Worker during main thread termination (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: typo 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 39c3b749316544f7056ea0556f3d6f83c40e2634..6c0b5a016b28845a962f6b285e1acd4b16805942 100644
--- a/src/d8.h
+++ b/src/d8.h
@@ -221,19 +221,25 @@ class Worker {
Worker();
~Worker();
- void StartExecuteInThread(Isolate* isolate, const char* script);
+ // Run the given script on this Worker. This function should only be called
+ // once, and should only be called by the thread that created the Worker.
+ void StartExecuteInThread(const char* script);
// Post a message to the worker's incoming message queue. The worker will
// take ownership of the SerializationData.
+ // This function should only be called by the thread that created the Worker.
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.
+ // This function should only be called by the thread that created the Worker.
SerializationData* GetMessage();
// Terminate the worker's event loop. Messages from the worker that have been
// queued can still be read via GetMessage().
+ // This function can be called by any thread.
void Terminate();
// Terminate and join the thread.
+ // This function can be called by any thread.
void WaitForThread();
private:
@@ -249,12 +255,6 @@ class Worker {
Worker* worker_;
};
- 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();
static void PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -264,8 +264,7 @@ class Worker {
SerializationDataQueue out_queue_;
base::Thread* thread_;
char* script_;
- base::Atomic32 state_;
- base::Atomic32 join_called_;
+ base::Atomic32 running_;
};
#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