| Index: src/d8.h
|
| diff --git a/src/d8.h b/src/d8.h
|
| index 3b06059323c81f1a4f7810d348d07a095790a22b..21cba88a3eda2fe82e4b99601947e7dabe414cd2 100644
|
| --- a/src/d8.h
|
| +++ b/src/d8.h
|
| @@ -8,6 +8,7 @@
|
| #ifndef V8_SHARED
|
| #include "src/allocation.h"
|
| #include "src/hashmap.h"
|
| +#include "src/list.h"
|
| #include "src/smart-pointers.h"
|
| #include "src/v8.h"
|
| #else
|
| @@ -167,6 +168,41 @@ class SourceGroup {
|
| int end_offset_;
|
| };
|
|
|
| +#ifndef V8_SHARED
|
| +class Worker {
|
| + public:
|
| + Worker();
|
| + ~Worker();
|
| +
|
| + void StartExecuteInThread(Isolate* isolate, const char* function_string,
|
| + const v8::SharedArrayBuffer::Contents& contents =
|
| + v8::SharedArrayBuffer::Contents());
|
| + Handle<Value> WaitForThread(Isolate* isolate);
|
| +
|
| + private:
|
| + class WorkerThread : public base::Thread {
|
| + public:
|
| + explicit WorkerThread(Worker* worker)
|
| + : base::Thread(base::Thread::Options("WorkerThread")),
|
| + worker_(worker) {}
|
| +
|
| + virtual void Run() { worker_->ExecuteInThread(); }
|
| +
|
| + private:
|
| + Worker* worker_;
|
| + };
|
| +
|
| + void ExecuteInThread();
|
| + void Cleanup();
|
| +
|
| + base::Mutex mutex_;
|
| + base::Thread* thread_;
|
| + char* script_;
|
| + char* result_json_;
|
| + v8::SharedArrayBuffer::Contents contents_;
|
| +};
|
| +#endif // !V8_SHARED
|
| +
|
|
|
| class ShellOptions {
|
| public:
|
| @@ -246,6 +282,7 @@ class Shell : public i::AllStatic {
|
| static void CollectGarbage(Isolate* isolate);
|
|
|
| #ifndef V8_SHARED
|
| + static void CleanupWorker(Isolate* isolate);
|
| static Handle<Array> GetCompletions(Isolate* isolate,
|
| Handle<String> text,
|
| Handle<String> full);
|
| @@ -289,6 +326,8 @@ class Shell : public i::AllStatic {
|
| args.GetReturnValue().Set(ReadFromStdin(args.GetIsolate()));
|
| }
|
| static void Load(const v8::FunctionCallbackInfo<v8::Value>& args);
|
| + static void WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args);
|
| + static void WorkerJoin(const v8::FunctionCallbackInfo<v8::Value>& args);
|
| // The OS object on the global object contains methods for performing
|
| // operating system calls:
|
| //
|
| @@ -341,6 +380,8 @@ class Shell : public i::AllStatic {
|
| static base::OS::MemoryMappedFile* counters_file_;
|
| static base::Mutex context_mutex_;
|
| static const base::TimeTicks kInitialTicks;
|
| + static Worker worker_;
|
| + static i::List<v8::SharedArrayBuffer::Contents> externalized_shared_contents_;
|
|
|
| static Counter* GetCounter(const char* name, bool is_histogram);
|
| static void InstallUtilityScript(Isolate* isolate);
|
|
|