Commit 473fb7d6 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[platform] Stop worker threads when the platform terminates

In principle it should be possible that worker threads continue their
execution even after the platform shuts down, because the background
tasks which execute on these threads are not allowed to access the
platform or the the isolate. However, the CompileTasks of the
OptimizingCompileDispatcher crash after the platform shut down. This CL
stops worker threads now when the platform shuts down to prevent any
task to execute after the shutdown of the platform.

R=rmcilroy@chromium.org
CC=machenbach@chromium.org

Change-Id: I3a723c3f6e875f78072600c3c3b95faad3d0ab32
Reviewed-on: https://chromium-review.googlesource.com/774463Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49412}
parent 6c431dde
......@@ -18,13 +18,16 @@ DefaultBackgroundTaskRunner::DefaultBackgroundTaskRunner(
}
DefaultBackgroundTaskRunner::~DefaultBackgroundTaskRunner() {
base::LockGuard<base::Mutex> guard(&lock_);
queue_.Terminate();
// This destructor is needed because we have unique_ptr to the WorkerThreads,
// und the {WorkerThread} class is forward declared in the header file.
}
void DefaultBackgroundTaskRunner::Terminate() {
base::LockGuard<base::Mutex> guard(&lock_);
terminated_ = true;
queue_.Terminate();
// Clearing the thread pool lets all worker threads join.
thread_pool_.clear();
}
void DefaultBackgroundTaskRunner::PostTask(std::unique_ptr<Task> task) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment