Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_D8_H_ | 5 #ifndef V8_D8_H_ |
| 6 #define V8_D8_H_ | 6 #define V8_D8_H_ |
| 7 | 7 |
| 8 #ifndef V8_SHARED | 8 #ifndef V8_SHARED |
| 9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
| 10 #include "src/hashmap.h" | 10 #include "src/hashmap.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 | 236 |
| 237 class Worker { | 237 class Worker { |
| 238 public: | 238 public: |
| 239 Worker(); | 239 Worker(); |
| 240 ~Worker(); | 240 ~Worker(); |
| 241 | 241 |
| 242 void StartExecuteInThread(Isolate* isolate, const char* script); | 242 void StartExecuteInThread(Isolate* isolate, const char* script); |
| 243 void PostMessage(SerializationData* data); | 243 void PostMessage(SerializationData* data); |
| 244 SerializationData* GetMessage(); | 244 SerializationData* GetMessage(); |
| 245 void Terminate(); | 245 void Terminate(); |
| 246 void WaitForThread(); | |
| 246 | 247 |
| 247 private: | 248 private: |
| 248 class WorkerThread : public base::Thread { | 249 class WorkerThread : public base::Thread { |
| 249 public: | 250 public: |
| 250 explicit WorkerThread(Worker* worker) | 251 explicit WorkerThread(Worker* worker) |
| 251 : base::Thread(base::Thread::Options("WorkerThread")), | 252 : base::Thread(base::Thread::Options("WorkerThread")), |
| 252 worker_(worker) {} | 253 worker_(worker) {} |
| 253 | 254 |
| 254 virtual void Run() { worker_->ExecuteInThread(); } | 255 virtual void Run() { worker_->ExecuteInThread(); } |
| 255 | 256 |
| 256 private: | 257 private: |
| 257 Worker* worker_; | 258 Worker* worker_; |
| 258 }; | 259 }; |
| 259 | 260 |
| 260 enum State { IDLE, RUNNING, TERMINATED }; | 261 enum State { IDLE, RUNNING, TERMINATING, STOPPED, JOINING, JOINED }; |
|
Jarin
2015/07/10 10:43:17
Could we have some descriptions of what the states
binji
2015/07/10 17:40:46
Done.
| |
| 261 | 262 |
| 262 void ExecuteInThread(); | 263 void ExecuteInThread(); |
| 263 void Cleanup(); | 264 void Cleanup(); |
| 264 static void PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args); | 265 static void PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 265 | 266 |
| 266 base::Semaphore in_semaphore_; | 267 base::Semaphore in_semaphore_; |
| 267 base::Semaphore out_semaphore_; | 268 base::Semaphore out_semaphore_; |
| 268 SerializationDataQueue in_queue_; | 269 SerializationDataQueue in_queue_; |
| 269 SerializationDataQueue out_queue_; | 270 SerializationDataQueue out_queue_; |
| 270 base::Thread* thread_; | 271 base::Thread* thread_; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 static void RunShell(Isolate* isolate); | 479 static void RunShell(Isolate* isolate); |
| 479 static bool SetOptions(int argc, char* argv[]); | 480 static bool SetOptions(int argc, char* argv[]); |
| 480 static Handle<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); | 481 static Handle<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); |
| 481 }; | 482 }; |
| 482 | 483 |
| 483 | 484 |
| 484 } // namespace v8 | 485 } // namespace v8 |
| 485 | 486 |
| 486 | 487 |
| 487 #endif // V8_D8_H_ | 488 #endif // V8_D8_H_ |
| OLD | NEW |