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

Unified Diff: gin/shell/gin_main.cc

Issue 2610473002: Use TaskScheduler instead of WorkerPool in v8_platform.cc. (Closed)
Patch Set: rebase 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/BUILD.gn ('k') | gin/shell_runner_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/shell/gin_main.cc
diff --git a/gin/shell/gin_main.cc b/gin/shell/gin_main.cc
index c7cf598756d8538415970900911efa9b264401d4..08703a4486889c816c20f8c204085c5b8447cbd8 100644
--- a/gin/shell/gin_main.cc
+++ b/gin/shell/gin_main.cc
@@ -14,6 +14,8 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
+#include "base/sys_info.h"
+#include "base/task_scheduler/task_scheduler.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gin/array_buffer.h"
#include "gin/modules/console.h"
@@ -73,34 +75,44 @@ int main(int argc, char** argv) {
#endif
base::MessageLoop message_loop;
+ base::TaskScheduler::CreateAndSetSimpleTaskScheduler(
+ base::SysInfo::NumberOfProcessors());
// Initialize the base::FeatureList since IsolateHolder can depend on it.
base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList));
- gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
- gin::IsolateHolder::kStableV8Extras,
- gin::ArrayBufferAllocator::SharedInstance());
- gin::IsolateHolder instance(base::ThreadTaskRunnerHandle::Get());
-
- gin::GinShellRunnerDelegate delegate;
- gin::ShellRunner runner(&delegate, instance.isolate());
-
{
- gin::Runner::Scope scope(&runner);
- runner.GetContextHolder()
- ->isolate()
- ->SetCaptureStackTraceForUncaughtExceptions(true);
+ gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
+ gin::IsolateHolder::kStableV8Extras,
+ gin::ArrayBufferAllocator::SharedInstance());
+ gin::IsolateHolder instance(base::ThreadTaskRunnerHandle::Get());
+
+ gin::GinShellRunnerDelegate delegate;
+ gin::ShellRunner runner(&delegate, instance.isolate());
+
+ {
+ gin::Runner::Scope scope(&runner);
+ runner.GetContextHolder()
+ ->isolate()
+ ->SetCaptureStackTraceForUncaughtExceptions(true);
+ }
+
+ base::CommandLine::StringVector args =
+ base::CommandLine::ForCurrentProcess()->GetArgs();
+ for (base::CommandLine::StringVector::const_iterator it = args.begin();
+ it != args.end(); ++it) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(gin::Run, runner.GetWeakPtr(), base::FilePath(*it)));
+ }
+
+ base::RunLoop().RunUntilIdle();
}
- base::CommandLine::StringVector args =
- base::CommandLine::ForCurrentProcess()->GetArgs();
- for (base::CommandLine::StringVector::const_iterator it = args.begin();
- it != args.end(); ++it) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(gin::Run, runner.GetWeakPtr(), base::FilePath(*it)));
- }
+ // gin::IsolateHolder waits for tasks running in TaskScheduler in its
+ // destructor and thus must be destroyed before TaskScheduler starts skipping
+ // CONTINUE_ON_SHUTDOWN tasks.
+ base::TaskScheduler::GetInstance()->Shutdown();
- base::RunLoop().RunUntilIdle();
return 0;
}
« no previous file with comments | « gin/BUILD.gn ('k') | gin/shell_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698