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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "include/libplatform/v8-tracing.h" | |
14 #include "include/v8-platform.h" | 13 #include "include/v8-platform.h" |
15 #include "src/base/macros.h" | 14 #include "src/base/macros.h" |
16 #include "src/base/platform/mutex.h" | 15 #include "src/base/platform/mutex.h" |
17 #include "src/libplatform/task-queue.h" | 16 #include "src/libplatform/task-queue.h" |
18 | 17 |
19 namespace v8 { | 18 namespace v8 { |
20 namespace platform { | 19 namespace platform { |
21 | 20 |
22 class TaskQueue; | 21 class TaskQueue; |
23 class Thread; | 22 class Thread; |
24 class WorkerThread; | 23 class WorkerThread; |
25 | 24 |
26 namespace tracing { | |
27 class TracingController; | |
28 } | |
29 | |
30 class DefaultPlatform : public Platform { | 25 class DefaultPlatform : public Platform { |
31 public: | 26 public: |
32 DefaultPlatform(); | 27 DefaultPlatform(); |
33 virtual ~DefaultPlatform(); | 28 virtual ~DefaultPlatform(); |
34 | 29 |
35 void SetThreadPoolSize(int thread_pool_size); | 30 void SetThreadPoolSize(int thread_pool_size); |
36 | 31 |
37 void EnsureInitialized(); | 32 void EnsureInitialized(); |
38 | 33 |
39 bool PumpMessageLoop(v8::Isolate* isolate); | 34 bool PumpMessageLoop(v8::Isolate* isolate); |
(...skipping 12 matching lines...) Expand all Loading... |
52 const char* GetCategoryGroupName( | 47 const char* GetCategoryGroupName( |
53 const uint8_t* category_enabled_flag) override; | 48 const uint8_t* category_enabled_flag) override; |
54 uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag, | 49 uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag, |
55 const char* name, const char* scope, uint64_t id, | 50 const char* name, const char* scope, uint64_t id, |
56 uint64_t bind_id, int32_t num_args, | 51 uint64_t bind_id, int32_t num_args, |
57 const char** arg_names, const uint8_t* arg_types, | 52 const char** arg_names, const uint8_t* arg_types, |
58 const uint64_t* arg_values, | 53 const uint64_t* arg_values, |
59 unsigned int flags) override; | 54 unsigned int flags) override; |
60 void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, | 55 void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, |
61 const char* name, uint64_t handle) override; | 56 const char* name, uint64_t handle) override; |
62 void SetTracingController(tracing::TracingController* tracing_controller); | 57 |
63 | 58 |
64 private: | 59 private: |
65 static const int kMaxThreadPoolSize; | 60 static const int kMaxThreadPoolSize; |
66 | 61 |
67 Task* PopTaskInMainThreadQueue(v8::Isolate* isolate); | 62 Task* PopTaskInMainThreadQueue(v8::Isolate* isolate); |
68 Task* PopTaskInMainThreadDelayedQueue(v8::Isolate* isolate); | 63 Task* PopTaskInMainThreadDelayedQueue(v8::Isolate* isolate); |
69 | 64 |
70 base::Mutex lock_; | 65 base::Mutex lock_; |
71 bool initialized_; | 66 bool initialized_; |
72 int thread_pool_size_; | 67 int thread_pool_size_; |
73 std::vector<WorkerThread*> thread_pool_; | 68 std::vector<WorkerThread*> thread_pool_; |
74 TaskQueue queue_; | 69 TaskQueue queue_; |
75 std::map<v8::Isolate*, std::queue<Task*> > main_thread_queue_; | 70 std::map<v8::Isolate*, std::queue<Task*> > main_thread_queue_; |
76 | 71 |
77 typedef std::pair<double, Task*> DelayedEntry; | 72 typedef std::pair<double, Task*> DelayedEntry; |
78 std::map<v8::Isolate*, | 73 std::map<v8::Isolate*, |
79 std::priority_queue<DelayedEntry, std::vector<DelayedEntry>, | 74 std::priority_queue<DelayedEntry, std::vector<DelayedEntry>, |
80 std::greater<DelayedEntry> > > | 75 std::greater<DelayedEntry> > > |
81 main_thread_delayed_queue_; | 76 main_thread_delayed_queue_; |
82 tracing::TracingController* tracing_controller_; | |
83 | 77 |
84 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); | 78 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); |
85 }; | 79 }; |
86 | 80 |
87 | 81 |
88 } // namespace platform | 82 } // namespace platform |
89 } // namespace v8 | 83 } // namespace v8 |
90 | 84 |
91 | 85 |
92 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ | 86 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ |
OLD | NEW |