Commit 4fea66bd authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Chromium LUCI CQ

[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 rename in v8
https://chromium-review.googlesource.com/c/v8/v8/+/2510969
The intend is to make the distinction between IsActive and IsValid obvious.

Change-Id: I196c889138bf244ff96568fc6f1e11b5aa4acd47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514480Reviewed-by: default avatarOmer Katz <omerkatz@chromium.org>
Reviewed-by: default avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832071}
parent 9f072287
...@@ -76,8 +76,8 @@ JobHandle& JobHandle::operator=(JobHandle&& other) { ...@@ -76,8 +76,8 @@ JobHandle& JobHandle::operator=(JobHandle&& other) {
return *this; return *this;
} }
bool JobHandle::IsCompleted() const { bool JobHandle::IsActive() const {
return task_source_->IsCompleted(); return task_source_->IsActive();
} }
void JobHandle::UpdatePriority(TaskPriority new_priority) { void JobHandle::UpdatePriority(TaskPriority new_priority) {
......
...@@ -94,8 +94,8 @@ class BASE_EXPORT JobHandle { ...@@ -94,8 +94,8 @@ class BASE_EXPORT JobHandle {
// Returns true if associated with a Job. // Returns true if associated with a Job.
explicit operator bool() const { return task_source_ != nullptr; } explicit operator bool() const { return task_source_ != nullptr; }
// Returns true if there's no work pending and no worker running. // Returns true if there's any work pending or any worker running.
bool IsCompleted() const; bool IsActive() const;
// Update this Job's priority. // Update this Job's priority.
void UpdatePriority(TaskPriority new_priority); void UpdatePriority(TaskPriority new_priority);
......
...@@ -237,11 +237,11 @@ size_t JobTaskSource::GetRemainingConcurrency() const { ...@@ -237,11 +237,11 @@ size_t JobTaskSource::GetRemainingConcurrency() const {
return max_concurrency - state.worker_count(); return max_concurrency - state.worker_count();
} }
bool JobTaskSource::IsCompleted() const { bool JobTaskSource::IsActive() const {
CheckedAutoLock auto_lock(worker_lock_); CheckedAutoLock auto_lock(worker_lock_);
auto state = state_.Load(); auto state = state_.Load();
return GetMaxConcurrency(state.worker_count()) == 0 && return GetMaxConcurrency(state.worker_count()) != 0 ||
state.worker_count() == 0; state.worker_count() != 0;
} }
size_t JobTaskSource::GetWorkerCount() const { size_t JobTaskSource::GetWorkerCount() const {
......
...@@ -74,7 +74,7 @@ class BASE_EXPORT JobTaskSource : public TaskSource { ...@@ -74,7 +74,7 @@ class BASE_EXPORT JobTaskSource : public TaskSource {
TaskSourceSortKey GetSortKey( TaskSourceSortKey GetSortKey(
bool disable_fair_scheduling = false) const override; bool disable_fair_scheduling = false) const override;
bool IsCompleted() const; bool IsActive() const;
size_t GetWorkerCount() const; size_t GetWorkerCount() const;
// Returns the maximum number of tasks from this TaskSource that can run // Returns the maximum number of tasks from this TaskSource that can run
......
...@@ -82,11 +82,11 @@ TEST_F(ThreadPoolJobTaskSourceTest, RunTasks) { ...@@ -82,11 +82,11 @@ TEST_F(ThreadPoolJobTaskSourceTest, RunTasks) {
std::move(task.task).Run(); std::move(task.task).Run();
EXPECT_EQ(0U, task_source->GetRemainingConcurrency()); EXPECT_EQ(0U, task_source->GetRemainingConcurrency());
EXPECT_FALSE(task_source->IsCompleted()); EXPECT_TRUE(task_source->IsActive());
// Returns false because the task source is out of tasks. // Returns false because the task source is out of tasks.
EXPECT_FALSE(registered_task_source.DidProcessTask()); EXPECT_FALSE(registered_task_source.DidProcessTask());
EXPECT_EQ(0U, task_source->GetWorkerCount()); EXPECT_EQ(0U, task_source->GetWorkerCount());
EXPECT_TRUE(task_source->IsCompleted()); EXPECT_FALSE(task_source->IsActive());
} }
} }
...@@ -348,13 +348,13 @@ TEST_F(ThreadPoolJobTaskSourceTest, RunJoinTaskInParallel) { ...@@ -348,13 +348,13 @@ TEST_F(ThreadPoolJobTaskSourceTest, RunJoinTaskInParallel) {
auto worker_task = registered_task_source.TakeTask(); auto worker_task = registered_task_source.TakeTask();
EXPECT_TRUE(task_source->WillJoin()); EXPECT_TRUE(task_source->WillJoin());
EXPECT_FALSE(task_source->IsCompleted()); EXPECT_TRUE(task_source->IsActive());
std::move(worker_task.task).Run(); std::move(worker_task.task).Run();
EXPECT_FALSE(registered_task_source.DidProcessTask()); EXPECT_FALSE(registered_task_source.DidProcessTask());
EXPECT_FALSE(task_source->RunJoinTask()); EXPECT_FALSE(task_source->RunJoinTask());
EXPECT_TRUE(task_source->IsCompleted()); EXPECT_FALSE(task_source->IsActive());
} }
// Verifies that a call to NotifyConcurrencyIncrease() calls the delegate // Verifies that a call to NotifyConcurrencyIncrease() calls the delegate
......
...@@ -322,8 +322,12 @@ class JobHandleImpl : public v8::JobHandle { ...@@ -322,8 +322,12 @@ class JobHandleImpl : public v8::JobHandle {
void Join() override { handle_.Join(); } void Join() override { handle_.Join(); }
void Cancel() override { handle_.Cancel(); } void Cancel() override { handle_.Cancel(); }
void CancelAndDetach() override { handle_.CancelAndDetach(); } void CancelAndDetach() override { handle_.CancelAndDetach(); }
bool IsCompleted() override { return handle_.IsCompleted(); } bool IsActive() override { return handle_.IsActive(); }
bool IsRunning() override { return !!handle_; } bool IsValid() override { return !!handle_; }
// TODO(etiennep): Cleanup once rename is complete.
bool IsCompleted() override { return !IsActive(); }
bool IsRunning() override { return IsValid(); }
private: private:
static base::TaskPriority ToBaseTaskPriority(v8::TaskPriority priority) { static base::TaskPriority ToBaseTaskPriority(v8::TaskPriority priority) {
......
...@@ -1214,7 +1214,7 @@ bool ThreadState::ConcurrentMarkingStep() { ...@@ -1214,7 +1214,7 @@ bool ThreadState::ConcurrentMarkingStep() {
} }
return false; return false;
} }
return marker_handle_.IsCompleted(); return !marker_handle_.IsActive();
} }
void ThreadState::IncrementalMarkingFinalize() { void ThreadState::IncrementalMarkingFinalize() {
......
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