Commit 4fb053d8 authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[Jobs API] Rename !IsCompleted -> IsActive

IsCompleted is backwards. For a more consistent api, the function is
renamed IsActive and logic is flipped.
Following up on https://chromium-review.googlesource.com/c/v8/v8/+/2461840
The intend is to make the distinction between IsActive and IsValid obvious.

Change-Id: Iaf00b9f6ffa8f1efe93ae29f09899737ef20f04d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2510969Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70901}
parent 07190e90
......@@ -226,8 +226,11 @@ class JobHandle {
/**
* Returns true if there's currently no work pending and no worker running.
* TODO(etiennep): Deprecate IsCompleted in favor of IsActive once implemented
* by all embedders.
*/
virtual bool IsCompleted() = 0;
virtual bool IsActive() { return !IsCompleted(); }
/**
* Returns true if associated with a Job and other methods may be called.
......
......@@ -205,7 +205,7 @@ bool ConcurrentMarkerBase::NotifyIncrementalMutatorStepCompleted() {
concurrent_marking_handle_->NotifyConcurrencyIncrease();
return false;
}
return concurrent_marking_handle_->IsCompleted();
return !concurrent_marking_handle_->IsActive();
}
void ConcurrentMarkerBase::IncreaseMarkingPriorityIfNeeded() {
......
......@@ -127,10 +127,10 @@ void DefaultJobState::CancelAndDetach() {
is_canceled_.store(true, std::memory_order_relaxed);
}
bool DefaultJobState::IsCompleted() {
bool DefaultJobState::IsActive() {
base::MutexGuard guard(&mutex_);
return job_task_->GetMaxConcurrency(active_workers_) == 0 &&
active_workers_ == 0;
return job_task_->GetMaxConcurrency(active_workers_) != 0 ||
active_workers_ != 0;
}
bool DefaultJobState::CanRunFirstTask() {
......@@ -235,7 +235,7 @@ void DefaultJobHandle::CancelAndDetach() {
state_ = nullptr;
}
bool DefaultJobHandle::IsCompleted() { return state_->IsCompleted(); }
bool DefaultJobHandle::IsActive() { return state_->IsActive(); }
void DefaultJobHandle::UpdatePriority(TaskPriority priority) {
state_->UpdatePriority(priority);
......
......@@ -55,7 +55,7 @@ class V8_PLATFORM_EXPORT DefaultJobState
void Join();
void CancelAndWait();
void CancelAndDetach();
bool IsCompleted();
bool IsActive();
// Must be called before running |job_task_| for the first time. If it returns
// true, then the worker thread must contribute and must call DidRunTask(), or
......@@ -113,7 +113,8 @@ class V8_PLATFORM_EXPORT DefaultJobHandle : public JobHandle {
void Join() override;
void Cancel() override;
void CancelAndDetach() override;
bool IsCompleted() override;
bool IsCompleted() override { return !IsActive(); }
bool IsActive() override;
bool IsRunning() override { return IsValid(); }
bool IsValid() override { return state_ != nullptr; }
......
......@@ -113,6 +113,7 @@ class MockPlatform final : public TestPlatform {
void Cancel() override { orig_handle_->Cancel(); }
void CancelAndDetach() override { orig_handle_->CancelAndDetach(); }
bool IsCompleted() override { return orig_handle_->IsCompleted(); }
bool IsActive() override { return orig_handle_->IsActive(); }
bool IsRunning() override { return orig_handle_->IsRunning(); }
bool IsValid() override { return orig_handle_->IsValid(); }
......
......@@ -128,6 +128,7 @@ class MockPlatform final : public TestPlatform {
bool IsRunning() override { return orig_handle_->IsRunning(); }
bool IsValid() override { return orig_handle_->IsValid(); }
bool IsCompleted() override { return orig_handle_->IsCompleted(); }
bool IsActive() override { return orig_handle_->IsActive(); }
private:
std::unique_ptr<JobHandle> orig_handle_;
......
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