OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_LIBPLATFORM_DEFAULT_PLATFORM_H_ | 5 #ifndef V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ |
6 #define V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ | 6 #define V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
11 #include <queue> | 11 #include <queue> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "include/libplatform/libplatform-export.h" | 14 #include "include/libplatform/libplatform-export.h" |
| 15 #include "include/libplatform/libplatform.h" |
15 #include "include/libplatform/v8-tracing.h" | 16 #include "include/libplatform/v8-tracing.h" |
16 #include "include/v8-platform.h" | 17 #include "include/v8-platform.h" |
17 #include "src/base/compiler-specific.h" | 18 #include "src/base/compiler-specific.h" |
18 #include "src/base/macros.h" | 19 #include "src/base/macros.h" |
19 #include "src/base/platform/mutex.h" | 20 #include "src/base/platform/mutex.h" |
20 #include "src/libplatform/task-queue.h" | 21 #include "src/libplatform/task-queue.h" |
21 | 22 |
22 namespace v8 { | 23 namespace v8 { |
23 namespace platform { | 24 namespace platform { |
24 | 25 |
25 class TaskQueue; | 26 class TaskQueue; |
26 class Thread; | 27 class Thread; |
27 class WorkerThread; | 28 class WorkerThread; |
28 | 29 |
29 namespace tracing { | 30 namespace tracing { |
30 class TracingController; | 31 class TracingController; |
31 } | 32 } |
32 | 33 |
33 class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) { | 34 class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) { |
34 public: | 35 public: |
35 DefaultPlatform(); | 36 explicit DefaultPlatform( |
| 37 IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled); |
36 virtual ~DefaultPlatform(); | 38 virtual ~DefaultPlatform(); |
37 | 39 |
38 void SetThreadPoolSize(int thread_pool_size); | 40 void SetThreadPoolSize(int thread_pool_size); |
39 | 41 |
40 void EnsureInitialized(); | 42 void EnsureInitialized(); |
41 | 43 |
42 bool PumpMessageLoop(v8::Isolate* isolate); | 44 bool PumpMessageLoop(v8::Isolate* isolate); |
43 | 45 |
44 void RunIdleTasks(v8::Isolate* isolate, double idle_time_in_seconds); | 46 void RunIdleTasks(v8::Isolate* isolate, double idle_time_in_seconds); |
45 | 47 |
(...skipping 28 matching lines...) Expand all Loading... |
74 private: | 76 private: |
75 static const int kMaxThreadPoolSize; | 77 static const int kMaxThreadPoolSize; |
76 | 78 |
77 Task* PopTaskInMainThreadQueue(v8::Isolate* isolate); | 79 Task* PopTaskInMainThreadQueue(v8::Isolate* isolate); |
78 Task* PopTaskInMainThreadDelayedQueue(v8::Isolate* isolate); | 80 Task* PopTaskInMainThreadDelayedQueue(v8::Isolate* isolate); |
79 IdleTask* PopTaskInMainThreadIdleQueue(v8::Isolate* isolate); | 81 IdleTask* PopTaskInMainThreadIdleQueue(v8::Isolate* isolate); |
80 | 82 |
81 base::Mutex lock_; | 83 base::Mutex lock_; |
82 bool initialized_; | 84 bool initialized_; |
83 int thread_pool_size_; | 85 int thread_pool_size_; |
| 86 IdleTaskSupport idle_task_support_; |
84 std::vector<WorkerThread*> thread_pool_; | 87 std::vector<WorkerThread*> thread_pool_; |
85 TaskQueue queue_; | 88 TaskQueue queue_; |
86 std::map<v8::Isolate*, std::queue<Task*>> main_thread_queue_; | 89 std::map<v8::Isolate*, std::queue<Task*>> main_thread_queue_; |
87 std::map<v8::Isolate*, std::queue<IdleTask*>> main_thread_idle_queue_; | 90 std::map<v8::Isolate*, std::queue<IdleTask*>> main_thread_idle_queue_; |
88 | 91 |
89 typedef std::pair<double, Task*> DelayedEntry; | 92 typedef std::pair<double, Task*> DelayedEntry; |
90 std::map<v8::Isolate*, | 93 std::map<v8::Isolate*, |
91 std::priority_queue<DelayedEntry, std::vector<DelayedEntry>, | 94 std::priority_queue<DelayedEntry, std::vector<DelayedEntry>, |
92 std::greater<DelayedEntry> > > | 95 std::greater<DelayedEntry> > > |
93 main_thread_delayed_queue_; | 96 main_thread_delayed_queue_; |
94 std::unique_ptr<tracing::TracingController> tracing_controller_; | 97 std::unique_ptr<tracing::TracingController> tracing_controller_; |
95 | 98 |
96 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); | 99 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); |
97 }; | 100 }; |
98 | 101 |
99 | 102 |
100 } // namespace platform | 103 } // namespace platform |
101 } // namespace v8 | 104 } // namespace v8 |
102 | 105 |
103 | 106 |
104 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ | 107 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ |
OLD | NEW |