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> |
(...skipping 23 matching lines...) Expand all Loading... |
34 public: | 34 public: |
35 DefaultPlatform(); | 35 DefaultPlatform(); |
36 virtual ~DefaultPlatform(); | 36 virtual ~DefaultPlatform(); |
37 | 37 |
38 void SetThreadPoolSize(int thread_pool_size); | 38 void SetThreadPoolSize(int thread_pool_size); |
39 | 39 |
40 void EnsureInitialized(); | 40 void EnsureInitialized(); |
41 | 41 |
42 bool PumpMessageLoop(v8::Isolate* isolate); | 42 bool PumpMessageLoop(v8::Isolate* isolate); |
43 | 43 |
| 44 void RunIdleTasks(v8::Isolate* isolate, double idle_time_in_seconds); |
| 45 |
44 // v8::Platform implementation. | 46 // v8::Platform implementation. |
45 size_t NumberOfAvailableBackgroundThreads() override; | 47 size_t NumberOfAvailableBackgroundThreads() override; |
46 void CallOnBackgroundThread(Task* task, | 48 void CallOnBackgroundThread(Task* task, |
47 ExpectedRuntime expected_runtime) override; | 49 ExpectedRuntime expected_runtime) override; |
48 void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override; | 50 void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override; |
49 void CallDelayedOnForegroundThread(Isolate* isolate, Task* task, | 51 void CallDelayedOnForegroundThread(Isolate* isolate, Task* task, |
50 double delay_in_seconds) override; | 52 double delay_in_seconds) override; |
51 void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) override; | 53 void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) override; |
52 bool IdleTasksEnabled(Isolate* isolate) override; | 54 bool IdleTasksEnabled(Isolate* isolate) override; |
53 double MonotonicallyIncreasingTime() override; | 55 double MonotonicallyIncreasingTime() override; |
(...skipping 13 matching lines...) Expand all Loading... |
67 void SetTracingController(tracing::TracingController* tracing_controller); | 69 void SetTracingController(tracing::TracingController* tracing_controller); |
68 | 70 |
69 void AddTraceStateObserver(TraceStateObserver* observer) override; | 71 void AddTraceStateObserver(TraceStateObserver* observer) override; |
70 void RemoveTraceStateObserver(TraceStateObserver* observer) override; | 72 void RemoveTraceStateObserver(TraceStateObserver* observer) override; |
71 | 73 |
72 private: | 74 private: |
73 static const int kMaxThreadPoolSize; | 75 static const int kMaxThreadPoolSize; |
74 | 76 |
75 Task* PopTaskInMainThreadQueue(v8::Isolate* isolate); | 77 Task* PopTaskInMainThreadQueue(v8::Isolate* isolate); |
76 Task* PopTaskInMainThreadDelayedQueue(v8::Isolate* isolate); | 78 Task* PopTaskInMainThreadDelayedQueue(v8::Isolate* isolate); |
| 79 IdleTask* PopTaskInMainThreadIdleQueue(v8::Isolate* isolate); |
77 | 80 |
78 base::Mutex lock_; | 81 base::Mutex lock_; |
79 bool initialized_; | 82 bool initialized_; |
80 int thread_pool_size_; | 83 int thread_pool_size_; |
81 std::vector<WorkerThread*> thread_pool_; | 84 std::vector<WorkerThread*> thread_pool_; |
82 TaskQueue queue_; | 85 TaskQueue queue_; |
83 std::map<v8::Isolate*, std::queue<Task*> > main_thread_queue_; | 86 std::map<v8::Isolate*, std::queue<Task*>> main_thread_queue_; |
| 87 std::map<v8::Isolate*, std::queue<IdleTask*>> main_thread_idle_queue_; |
84 | 88 |
85 typedef std::pair<double, Task*> DelayedEntry; | 89 typedef std::pair<double, Task*> DelayedEntry; |
86 std::map<v8::Isolate*, | 90 std::map<v8::Isolate*, |
87 std::priority_queue<DelayedEntry, std::vector<DelayedEntry>, | 91 std::priority_queue<DelayedEntry, std::vector<DelayedEntry>, |
88 std::greater<DelayedEntry> > > | 92 std::greater<DelayedEntry> > > |
89 main_thread_delayed_queue_; | 93 main_thread_delayed_queue_; |
90 std::unique_ptr<tracing::TracingController> tracing_controller_; | 94 std::unique_ptr<tracing::TracingController> tracing_controller_; |
91 | 95 |
92 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); | 96 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); |
93 }; | 97 }; |
94 | 98 |
95 | 99 |
96 } // namespace platform | 100 } // namespace platform |
97 } // namespace v8 | 101 } // namespace v8 |
98 | 102 |
99 | 103 |
100 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ | 104 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ |
OLD | NEW |