V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
default-worker-threads-task-runner.h
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_LIBPLATFORM_DEFAULT_WORKER_THREADS_TASK_RUNNER_H_
6 #define V8_LIBPLATFORM_DEFAULT_WORKER_THREADS_TASK_RUNNER_H_
7 
8 #include "include/v8-platform.h"
9 #include "src/libplatform/task-queue.h"
10 
11 namespace v8 {
12 namespace platform {
13 
14 class Thread;
15 class WorkerThread;
16 
17 class V8_PLATFORM_EXPORT DefaultWorkerThreadsTaskRunner
18  : public NON_EXPORTED_BASE(TaskRunner) {
19  public:
20  DefaultWorkerThreadsTaskRunner(uint32_t thread_pool_size);
21 
23 
24  void Terminate();
25 
26  // v8::TaskRunner implementation.
27  void PostTask(std::unique_ptr<Task> task) override;
28 
29  void PostDelayedTask(std::unique_ptr<Task> task,
30  double delay_in_seconds) override;
31 
32  void PostIdleTask(std::unique_ptr<IdleTask> task) override;
33 
34  bool IdleTasksEnabled() override;
35 
36  private:
37  bool terminated_ = false;
38  base::Mutex lock_;
39  TaskQueue queue_;
40  std::vector<std::unique_ptr<WorkerThread>> thread_pool_;
41 };
42 
43 } // namespace platform
44 } // namespace v8
45 #endif // V8_LIBPLATFORM_DEFAULT_WORKER_THREADS_TASK_RUNNER_H_
Definition: libplatform.h:13