forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make TaskGraphWorkQueue more robust against changing dependencies
Currently, if a task in the TaskGraphWorkQueue goes from having no dependencies to having dependencies, the TaskGraphWorkQueue may incorrectly schedule it to run twice. This change adds an additional check to make sure we handle this case. R=vmpstr BUG=652718 CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel Review-Url: https://codereview.chromium.org/2643153002 Cr-Commit-Position: refs/heads/master@{#445425}
- Loading branch information
ericrk
authored and
Commit bot
committed
Jan 23, 2017
1 parent
bc99b5b
commit 0f9ee98
Showing
3 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "cc/raster/task_graph_work_queue.h" | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace cc { | ||
namespace { | ||
|
||
class FakeTaskImpl : public Task { | ||
public: | ||
FakeTaskImpl() {} | ||
|
||
// Overridden from Task: | ||
void RunOnWorkerThread() override{}; | ||
|
||
private: | ||
~FakeTaskImpl() override {} | ||
DISALLOW_COPY_AND_ASSIGN(FakeTaskImpl); | ||
}; | ||
|
||
TEST(TaskGraphWorkQueueTest, TestChangingDependency) { | ||
TaskGraphWorkQueue work_queue; | ||
NamespaceToken token = work_queue.GenerateNamespaceToken(); | ||
|
||
// Create a graph with one task | ||
TaskGraph graph1; | ||
scoped_refptr<FakeTaskImpl> task(new FakeTaskImpl()); | ||
graph1.nodes.push_back(TaskGraph::Node(task.get(), 0u, 0u, 0u)); | ||
|
||
// Schedule the graph | ||
work_queue.ScheduleTasks(token, &graph1); | ||
|
||
// Run the task. | ||
TaskGraphWorkQueue::PrioritizedTask prioritized_task = | ||
work_queue.GetNextTaskToRun(0u); | ||
work_queue.CompleteTask(std::move(prioritized_task)); | ||
|
||
// Create a graph where task1 has a dependency | ||
TaskGraph graph2; | ||
scoped_refptr<FakeTaskImpl> dependency_task(new FakeTaskImpl()); | ||
graph2.nodes.push_back(TaskGraph::Node(task.get(), 0u, 0u, 1u)); | ||
graph2.nodes.push_back(TaskGraph::Node(dependency_task.get(), 0u, 0u, 0u)); | ||
graph2.edges.push_back(TaskGraph::Edge(dependency_task.get(), task.get())); | ||
|
||
// Schedule the second graph. | ||
work_queue.ScheduleTasks(token, &graph2); | ||
|
||
// Run the |dependency_task| | ||
TaskGraphWorkQueue::PrioritizedTask prioritized_dependency_task = | ||
work_queue.GetNextTaskToRun(0u); | ||
EXPECT_EQ(prioritized_dependency_task.task.get(), dependency_task.get()); | ||
work_queue.CompleteTask(std::move(prioritized_dependency_task)); | ||
|
||
// We should have no tasks to run, as the dependent task already completed. | ||
EXPECT_FALSE(work_queue.HasReadyToRunTasks()); | ||
} | ||
|
||
} // namespace | ||
} // namespace cc |