| Index: gin/v8_platform.cc
|
| diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
|
| index 9c69aa97721e78c151e9c1e44866586d4e32006a..4fe7c7ceced0d5f4d164ea14c548aca3aba0b1d6 100644
|
| --- a/gin/v8_platform.cc
|
| +++ b/gin/v8_platform.cc
|
| @@ -7,8 +7,7 @@
|
| #include "base/bind.h"
|
| #include "base/location.h"
|
| #include "base/sys_info.h"
|
| -#include "base/task_scheduler/post_task.h"
|
| -#include "base/task_scheduler/task_scheduler.h"
|
| +#include "base/threading/worker_pool.h"
|
| #include "base/trace_event/trace_event.h"
|
| #include "gin/per_isolate_data.h"
|
|
|
| @@ -43,11 +42,6 @@ class IdleTaskWithLocker : public v8::IdleTask {
|
| DISALLOW_COPY_AND_ASSIGN(IdleTaskWithLocker);
|
| };
|
|
|
| -base::TaskTraits GetBackgroundThreadTaskTraits() {
|
| - return base::TaskTraits().WithShutdownBehavior(
|
| - base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN);
|
| -}
|
| -
|
| } // namespace
|
|
|
| // static
|
| @@ -58,16 +52,25 @@ V8Platform::V8Platform() {}
|
| V8Platform::~V8Platform() {}
|
|
|
| size_t V8Platform::NumberOfAvailableBackgroundThreads() {
|
| - return base::TaskScheduler::GetInstance()
|
| - ->GetMaxConcurrentTasksWithTraitsDeprecated(
|
| - GetBackgroundThreadTaskTraits());
|
| + // WorkerPool will currently always create additional threads for posted
|
| + // background tasks, unless there are threads sitting idle (on posix).
|
| + // Indicate that V8 should create no more than the number of cores available,
|
| + // reserving one core for the main thread.
|
| + const size_t available_cores =
|
| + static_cast<size_t>(base::SysInfo::NumberOfProcessors());
|
| + if (available_cores > 1) {
|
| + return available_cores - 1;
|
| + }
|
| + return 1;
|
| }
|
|
|
| void V8Platform::CallOnBackgroundThread(
|
| v8::Task* task,
|
| v8::Platform::ExpectedRuntime expected_runtime) {
|
| - base::PostTaskWithTraits(FROM_HERE, GetBackgroundThreadTaskTraits(),
|
| - base::Bind(&v8::Task::Run, base::Owned(task)));
|
| + base::WorkerPool::PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&v8::Task::Run, base::Owned(task)),
|
| + expected_runtime == v8::Platform::kLongRunningTask);
|
| }
|
|
|
| void V8Platform::CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) {
|
|
|