Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3717)

Unified Diff: cc/raster/task_graph_runner.h

Issue 1739993004: content: Implement dynamic priorities for raster threads. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: preparing for checkin. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/raster/task_graph_runner.h
diff --git a/cc/raster/task_graph_runner.h b/cc/raster/task_graph_runner.h
index 23094ef5a7ef3c81a6cae0fbde931c57c11efe98..53fdea885b0801eadd0979694dede01bb695c577 100644
--- a/cc/raster/task_graph_runner.h
+++ b/cc/raster/task_graph_runner.h
@@ -15,12 +15,23 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/threading/simple_thread.h"
+#include "base/time/time.h"
#include "cc/base/cc_export.h"
+#include "cc/raster/task_category.h"
namespace cc {
class TaskGraphRunner;
+class CC_EXPORT TaskWorker {
+ public:
+ // TODO(prashant.n): Find better names.
+ virtual bool TaskSpeedup() = 0;
+ virtual bool TaskSlowdown() = 0;
+ virtual bool TaskDone() = 0;
+};
+
// A task which can be run by a TaskGraphRunner. To run a Task, it should be
// inserted into a TaskGraph, which can then be scheduled on the
// TaskGraphRunner.
@@ -33,6 +44,10 @@ class CC_EXPORT Task : public base::RefCountedThreadSafe<Task> {
// safety.
virtual void RunOnWorkerThread() = 0;
+ TaskWorker* GetTaskWorker() { return worker_; }
+ void AttachTaskWorker(TaskWorker* worker);
+ void DetachTaskWorker();
+
void WillRun();
void DidRun();
bool HasFinishedRunning() const;
@@ -43,10 +58,25 @@ class CC_EXPORT Task : public base::RefCountedThreadSafe<Task> {
Task();
virtual ~Task();
+ TaskWorker* worker_;
bool will_run_;
bool did_run_;
};
+class CC_EXPORT AutoDetachTaskWorker {
+ public:
+ explicit AutoDetachTaskWorker(Task& task, TaskWorker* worker) : task_(task) {
+ DCHECK(worker);
+ task_.AttachTaskWorker(worker);
+ }
+
+ ~AutoDetachTaskWorker() { task_.DetachTaskWorker(); }
+
+ private:
+ Task& task_;
+ DISALLOW_COPY_AND_ASSIGN(AutoDetachTaskWorker);
+};
+
// A task dependency graph describes the order in which to execute a set
// of tasks. Dependencies are represented as edges. Each node is assigned
// a category, a priority and a run count that matches the number of

Powered by Google App Engine
This is Rietveld 408576698