Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Unified Diff: gin/v8_platform.cc

Issue 2711703002: Revert of Use TaskScheduler instead of WorkerPool in v8_platform.cc. (Closed)
Patch Set: another patchset to kick off tryjobs Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/test/v8_test.h ('k') | mojo/edk/js/tests/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « gin/test/v8_test.h ('k') | mojo/edk/js/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698