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