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 <queue> | 10 #include <queue> |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 bool PumpMessageLoop(v8::Isolate* isolate); | 34 bool PumpMessageLoop(v8::Isolate* isolate); |
35 | 35 |
36 // v8::Platform implementation. | 36 // v8::Platform implementation. |
37 virtual void CallOnBackgroundThread( | 37 virtual void CallOnBackgroundThread( |
38 Task* task, ExpectedRuntime expected_runtime) override; | 38 Task* task, ExpectedRuntime expected_runtime) override; |
39 virtual void CallOnForegroundThread(v8::Isolate* isolate, | 39 virtual void CallOnForegroundThread(v8::Isolate* isolate, |
40 Task* task) override; | 40 Task* task) override; |
41 virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task, | 41 virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task, |
42 double delay_in_seconds) override; | 42 double delay_in_seconds) override; |
| 43 virtual void CallIdleOnForegroundThread(Isolate* isolate, |
| 44 IdleTask* task) override; |
| 45 virtual bool IdleTasksEnabled(Isolate* isolate) override; |
43 double MonotonicallyIncreasingTime() override; | 46 double MonotonicallyIncreasingTime() override; |
44 | 47 |
45 private: | 48 private: |
46 static const int kMaxThreadPoolSize; | 49 static const int kMaxThreadPoolSize; |
47 | 50 |
48 Task* PopTaskInMainThreadQueue(v8::Isolate* isolate); | 51 Task* PopTaskInMainThreadQueue(v8::Isolate* isolate); |
49 Task* PopTaskInMainThreadDelayedQueue(v8::Isolate* isolate); | 52 Task* PopTaskInMainThreadDelayedQueue(v8::Isolate* isolate); |
50 | 53 |
51 base::Mutex lock_; | 54 base::Mutex lock_; |
52 bool initialized_; | 55 bool initialized_; |
53 int thread_pool_size_; | 56 int thread_pool_size_; |
54 std::vector<WorkerThread*> thread_pool_; | 57 std::vector<WorkerThread*> thread_pool_; |
55 TaskQueue queue_; | 58 TaskQueue queue_; |
56 std::map<v8::Isolate*, std::queue<Task*> > main_thread_queue_; | 59 std::map<v8::Isolate*, std::queue<Task*> > main_thread_queue_; |
57 | 60 |
58 typedef std::pair<double, Task*> DelayedEntry; | 61 typedef std::pair<double, Task*> DelayedEntry; |
59 std::map<v8::Isolate*, | 62 std::map<v8::Isolate*, |
60 std::priority_queue<DelayedEntry, std::vector<DelayedEntry>, | 63 std::priority_queue<DelayedEntry, std::vector<DelayedEntry>, |
61 std::greater<DelayedEntry> > > | 64 std::greater<DelayedEntry> > > |
62 main_thread_delayed_queue_; | 65 main_thread_delayed_queue_; |
63 | 66 |
64 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); | 67 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); |
65 }; | 68 }; |
66 | 69 |
67 | 70 |
68 } } // namespace v8::platform | 71 } } // namespace v8::platform |
69 | 72 |
70 | 73 |
71 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ | 74 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ |
OLD | NEW |