| 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 <map> |
| 9 #include <queue> |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 10 #include "include/v8-platform.h" | 12 #include "include/v8-platform.h" |
| 11 #include "src/base/macros.h" | 13 #include "src/base/macros.h" |
| 12 #include "src/base/platform/mutex.h" | 14 #include "src/base/platform/mutex.h" |
| 13 #include "src/libplatform/task-queue.h" | 15 #include "src/libplatform/task-queue.h" |
| 14 | 16 |
| 15 namespace v8 { | 17 namespace v8 { |
| 16 namespace platform { | 18 namespace platform { |
| 17 | 19 |
| 18 class TaskQueue; | 20 class TaskQueue; |
| 19 class Thread; | 21 class Thread; |
| 20 class WorkerThread; | 22 class WorkerThread; |
| 21 | 23 |
| 22 class DefaultPlatform : public Platform { | 24 class DefaultPlatform : public Platform { |
| 23 public: | 25 public: |
| 24 DefaultPlatform(); | 26 DefaultPlatform(); |
| 25 virtual ~DefaultPlatform(); | 27 virtual ~DefaultPlatform(); |
| 26 | 28 |
| 27 void SetThreadPoolSize(int thread_pool_size); | 29 void SetThreadPoolSize(int thread_pool_size); |
| 28 | 30 |
| 29 void EnsureInitialized(); | 31 void EnsureInitialized(); |
| 30 | 32 |
| 33 bool PumpMessageLoop(v8::Isolate* isolate); |
| 34 |
| 31 // v8::Platform implementation. | 35 // v8::Platform implementation. |
| 32 virtual void CallOnBackgroundThread( | 36 virtual void CallOnBackgroundThread( |
| 33 Task *task, ExpectedRuntime expected_runtime) V8_OVERRIDE; | 37 Task* task, ExpectedRuntime expected_runtime) V8_OVERRIDE; |
| 34 virtual void CallOnForegroundThread(v8::Isolate *isolate, | 38 virtual void CallOnForegroundThread(v8::Isolate* isolate, |
| 35 Task *task) V8_OVERRIDE; | 39 Task* task) V8_OVERRIDE; |
| 36 | 40 |
| 37 private: | 41 private: |
| 38 static const int kMaxThreadPoolSize; | 42 static const int kMaxThreadPoolSize; |
| 39 | 43 |
| 40 base::Mutex lock_; | 44 base::Mutex lock_; |
| 41 bool initialized_; | 45 bool initialized_; |
| 42 int thread_pool_size_; | 46 int thread_pool_size_; |
| 43 std::vector<WorkerThread*> thread_pool_; | 47 std::vector<WorkerThread*> thread_pool_; |
| 44 TaskQueue queue_; | 48 TaskQueue queue_; |
| 49 std::map<v8::Isolate*, std::queue<Task*> > main_thread_queue_; |
| 45 | 50 |
| 46 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); | 51 DISALLOW_COPY_AND_ASSIGN(DefaultPlatform); |
| 47 }; | 52 }; |
| 48 | 53 |
| 49 | 54 |
| 50 } } // namespace v8::platform | 55 } } // namespace v8::platform |
| 51 | 56 |
| 52 | 57 |
| 53 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ | 58 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ |
| OLD | NEW |