OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ | |
6 #define V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "include/v8-inspector.h" | |
11 #include "include/v8-platform.h" | |
12 #include "include/v8.h" | |
13 #include "src/base/macros.h" | |
14 #include "src/base/platform/platform.h" | |
15 #include "src/locked-queue-inl.h" | |
16 | |
17 class TaskRunner : public v8::base::Thread { | |
18 public: | |
19 class Task { | |
20 public: | |
21 virtual ~Task() {} | |
22 virtual bool is_protocol_task() = 0; | |
23 virtual void Run(v8::Local<v8::Context>) = 0; | |
24 }; | |
25 | |
26 explicit TaskRunner(v8::ExtensionConfiguration* extensions, | |
27 v8::base::Semaphore* ready); | |
28 virtual ~TaskRunner(); | |
29 | |
30 // Thread implementation. | |
31 void Run() override; | |
32 | |
33 // Should be called from the same thread and only from task. | |
34 void RunMessageLoop(bool only_protocol); | |
35 void QuitMessageLoop(); | |
36 | |
37 // TaskRunner takes ownership. | |
38 void Append(Task* task); | |
39 | |
40 static TaskRunner* FromContext(v8::Local<v8::Context>); | |
41 | |
42 private: | |
43 void InitializeContext(); | |
44 Task* GetNext(bool only_protocol); | |
45 | |
46 v8::ExtensionConfiguration* extensions_; | |
47 v8::base::Semaphore* ready_; | |
dgozman
2016/09/24 00:56:10
ready_semaphore_
kozy
2016/09/26 01:44:08
Done.
| |
48 | |
49 v8::Isolate* isolate_; | |
50 v8::Global<v8::Context> context_; | |
51 | |
52 v8::internal::LockedQueue<Task*> queue_; | |
dgozman
2016/09/24 00:56:10
// deferred_queue_ combined with queue_ (in this o
kozy
2016/09/26 01:44:08
Done.
| |
53 v8::internal::LockedQueue<Task*> deffered_queue_; | |
54 v8::base::Semaphore process_queue_semaphore_; | |
55 | |
56 int nested_loops_; | |
dgozman
2016/09/24 00:56:10
nested_loop_count_;
kozy
2016/09/26 01:44:08
Done.
| |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(TaskRunner); | |
59 }; | |
60 | |
61 class ExecuteStringTask : public TaskRunner::Task { | |
62 public: | |
63 explicit ExecuteStringTask(const std::string& expression); | |
64 bool is_protocol_task() override { return false; } | |
65 | |
66 void Run(v8::Local<v8::Context>) override; | |
67 | |
68 private: | |
69 std::string expression_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask); | |
72 }; | |
73 | |
74 #endif // V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ | |
OLD | NEW |