5 #ifndef V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ 6 #define V8_LIBPLATFORM_DEFAULT_PLATFORM_H_ 14 #include "include/libplatform/libplatform-export.h" 15 #include "include/libplatform/libplatform.h" 16 #include "include/libplatform/v8-tracing.h" 17 #include "include/v8-platform.h" 18 #include "src/base/compiler-specific.h" 19 #include "src/base/macros.h" 20 #include "src/base/platform/mutex.h" 21 #include "src/base/platform/time.h" 28 class DefaultForegroundTaskRunner;
29 class DefaultWorkerThreadsTaskRunner;
30 class DefaultPageAllocator;
35 IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
36 std::unique_ptr<v8::TracingController> tracing_controller = {});
40 void SetThreadPoolSize(
int thread_pool_size);
42 void EnsureBackgroundTaskRunnerInitialized();
46 MessageLoopBehavior behavior = MessageLoopBehavior::kDoNotWait);
48 void RunIdleTasks(v8::Isolate* isolate,
double idle_time_in_seconds);
50 void SetTracingController(
51 std::unique_ptr<v8::TracingController> tracing_controller);
53 using TimeFunction = double (*)();
55 void SetTimeFunctionForTesting(TimeFunction time_function);
58 int NumberOfWorkerThreads()
override;
59 std::shared_ptr<TaskRunner> GetForegroundTaskRunner(
60 v8::Isolate* isolate)
override;
61 void CallOnWorkerThread(std::unique_ptr<Task> task)
override;
62 void CallDelayedOnWorkerThread(std::unique_ptr<Task> task,
63 double delay_in_seconds)
override;
64 void CallOnForegroundThread(v8::Isolate* isolate,
Task* task)
override;
65 void CallDelayedOnForegroundThread(Isolate* isolate,
Task* task,
66 double delay_in_seconds)
override;
67 void CallIdleOnForegroundThread(Isolate* isolate,
IdleTask* task)
override;
68 bool IdleTasksEnabled(Isolate* isolate)
override;
69 double MonotonicallyIncreasingTime()
override;
70 double CurrentClockTimeMillis()
override;
72 StackTracePrinter GetStackTracePrinter()
override;
76 static const int kMaxThreadPoolSize;
79 int thread_pool_size_;
80 IdleTaskSupport idle_task_support_;
81 std::shared_ptr<DefaultWorkerThreadsTaskRunner> worker_threads_task_runner_;
82 std::map<v8::Isolate*, std::shared_ptr<DefaultForegroundTaskRunner>>
83 foreground_task_runner_map_;
85 std::unique_ptr<TracingController> tracing_controller_;
86 std::unique_ptr<PageAllocator> page_allocator_;
88 TimeFunction time_function_for_testing_;
96 #endif // V8_LIBPLATFORM_DEFAULT_PLATFORM_H_