[cleanup] Inline one-line CancelAndWait method
Very minor cleanup to reduce code complexity. R=mstarzinger@chromium.org Bug: chromium:869420 Change-Id: I53d1776792b3918d489fe002e2cb17b7a3e0ff73 Reviewed-on: https://chromium-review.googlesource.com/1158686 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#54849}
This commit is contained in:
parent
2d40e2f445
commit
94087c8038
@ -87,7 +87,6 @@ class CompilationState {
|
|||||||
void ScheduleUnitForFinishing(std::unique_ptr<WasmCompilationUnit> unit,
|
void ScheduleUnitForFinishing(std::unique_ptr<WasmCompilationUnit> unit,
|
||||||
WasmCompilationUnit::CompilationMode mode);
|
WasmCompilationUnit::CompilationMode mode);
|
||||||
|
|
||||||
void CancelAndWait();
|
|
||||||
void OnBackgroundTaskStopped();
|
void OnBackgroundTaskStopped();
|
||||||
void RestartBackgroundTasks(size_t max = std::numeric_limits<size_t>::max());
|
void RestartBackgroundTasks(size_t max = std::numeric_limits<size_t>::max());
|
||||||
// Only one foreground thread (finisher) is allowed to run at a time.
|
// Only one foreground thread (finisher) is allowed to run at a time.
|
||||||
@ -154,8 +153,6 @@ class CompilationState {
|
|||||||
// the given {ErrorThrower} can be done at most once.
|
// the given {ErrorThrower} can be done at most once.
|
||||||
std::vector<std::function<void(CompilationEvent, ErrorThrower*)>> callbacks_;
|
std::vector<std::function<void(CompilationEvent, ErrorThrower*)>> callbacks_;
|
||||||
|
|
||||||
// When canceling the background_task_manager_, use {CancelAndWait} on
|
|
||||||
// the CompilationState in order to cleanly clean up.
|
|
||||||
CancelableTaskManager background_task_manager_;
|
CancelableTaskManager background_task_manager_;
|
||||||
CancelableTaskManager foreground_task_manager_;
|
CancelableTaskManager foreground_task_manager_;
|
||||||
std::shared_ptr<v8::TaskRunner> foreground_task_runner_;
|
std::shared_ptr<v8::TaskRunner> foreground_task_runner_;
|
||||||
@ -2734,7 +2731,7 @@ CompilationState::CompilationState(internal::Isolate* isolate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompilationState::~CompilationState() {
|
CompilationState::~CompilationState() {
|
||||||
CancelAndWait();
|
background_task_manager_.CancelAndWait();
|
||||||
foreground_task_manager_.CancelAndWait();
|
foreground_task_manager_.CancelAndWait();
|
||||||
NotifyOnEvent(CompilationEvent::kDestroyed, nullptr);
|
NotifyOnEvent(CompilationEvent::kDestroyed, nullptr);
|
||||||
}
|
}
|
||||||
@ -2823,7 +2820,7 @@ void CompilationState::OnFinishedUnit() {
|
|||||||
--outstanding_units_;
|
--outstanding_units_;
|
||||||
|
|
||||||
if (outstanding_units_ == 0) {
|
if (outstanding_units_ == 0) {
|
||||||
CancelAndWait();
|
background_task_manager_.CancelAndWait();
|
||||||
baseline_compilation_finished_ = true;
|
baseline_compilation_finished_ = true;
|
||||||
|
|
||||||
DCHECK(compile_mode_ == CompileMode::kRegular ||
|
DCHECK(compile_mode_ == CompileMode::kRegular ||
|
||||||
@ -2867,10 +2864,6 @@ void CompilationState::ScheduleUnitForFinishing(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilationState::CancelAndWait() {
|
|
||||||
background_task_manager_.CancelAndWait();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CompilationState::OnBackgroundTaskStopped() {
|
void CompilationState::OnBackgroundTaskStopped() {
|
||||||
base::LockGuard<base::Mutex> guard(&mutex_);
|
base::LockGuard<base::Mutex> guard(&mutex_);
|
||||||
DCHECK_LE(1, num_background_tasks_);
|
DCHECK_LE(1, num_background_tasks_);
|
||||||
@ -2924,7 +2917,7 @@ void CompilationState::Abort() {
|
|||||||
base::LockGuard<base::Mutex> guard(&mutex_);
|
base::LockGuard<base::Mutex> guard(&mutex_);
|
||||||
failed_ = true;
|
failed_ = true;
|
||||||
}
|
}
|
||||||
CancelAndWait();
|
background_task_manager_.CancelAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilationState::NotifyOnEvent(CompilationEvent event,
|
void CompilationState::NotifyOnEvent(CompilationEvent event,
|
||||||
|
Loading…
Reference in New Issue
Block a user