Index: content/renderer/raster_worker_pool.h |
diff --git a/content/renderer/raster_worker_pool.h b/content/renderer/raster_worker_pool.h |
index b8b4f358f2f2497dd9d5a6ad4f3a9efdab696386..0e09adf1493f630fc273b09c187481f15075a4eb 100644 |
--- a/content/renderer/raster_worker_pool.h |
+++ b/content/renderer/raster_worker_pool.h |
@@ -12,6 +12,7 @@ |
#include "base/task_runner.h" |
#include "base/threading/simple_thread.h" |
#include "cc/raster/task_graph_runner.h" |
+#include "cc/raster/task_graph_work_queue.h" |
#include "content/common/content_export.h" |
namespace content { |
@@ -24,10 +25,9 @@ namespace content { |
// parallel with other instances of sequenced task runners. |
// It's also possible to get the underlying TaskGraphRunner to schedule a graph |
// of tasks with their dependencies. |
-// TODO(reveman): make TaskGraphRunner an abstract interface and have this |
-// WorkerPool class implement it. |
class CONTENT_EXPORT RasterWorkerPool |
: public base::TaskRunner, |
+ public cc::TaskGraphRunner, |
public base::DelegateSimpleThread::Delegate { |
public: |
RasterWorkerPool(); |
@@ -38,9 +38,17 @@ class CONTENT_EXPORT RasterWorkerPool |
base::TimeDelta delay) override; |
bool RunsTasksOnCurrentThread() const override; |
+ // Overridden from cc::TaskGraphRunner: |
+ void ScheduleTasks(cc::NamespaceToken token, cc::TaskGraph* graph) override; |
+ void WaitForTasksToFinishRunning(cc::NamespaceToken token) override; |
+ void CollectCompletedTasks(cc::NamespaceToken token, |
+ cc::Task::Vector* completed_tasks) override; |
+ |
// Overridden from base::DelegateSimpleThread::Delegate: |
void Run() override; |
+ void FlushForTesting(); |
+ |
// Spawn |num_threads| number of threads and start running work on the |
// worker threads. |
void Start(int num_threads, |
@@ -52,7 +60,7 @@ class CONTENT_EXPORT RasterWorkerPool |
// terminated. |
void Shutdown(); |
- cc::TaskGraphRunner* GetTaskGraphRunner() { return &task_graph_runner_; } |
+ cc::TaskGraphRunner* GetTaskGraphRunner() { return this; } |
// Create a new sequenced task graph runner. |
scoped_refptr<base::SequencedTaskRunner> CreateSequencedTaskRunner(); |
@@ -64,6 +72,10 @@ class CONTENT_EXPORT RasterWorkerPool |
class RasterWorkerPoolSequencedTaskRunner; |
friend class RasterWorkerPoolSequencedTaskRunner; |
+ // Run next task. Caller must acquire |lock_| prior to calling this function |
+ // and make sure at least one task is ready to run. |
+ void RunTaskWithLockAcquired(); |
+ |
// Simple Task for the TaskGraphRunner that wraps a closure. |
// This class is used to schedule TaskRunner tasks on the |
// |task_graph_runner_|. |
@@ -83,9 +95,13 @@ class CONTENT_EXPORT RasterWorkerPool |
DISALLOW_COPY_AND_ASSIGN(ClosureTask); |
}; |
+ void ScheduleTasksWithLockAcquired(cc::NamespaceToken token, |
+ cc::TaskGraph* graph); |
+ void CollectCompletedTasksWithLockAcquired(cc::NamespaceToken token, |
+ cc::Task::Vector* completed_tasks); |
+ |
// The actual threads where work is done. |
ScopedVector<base::DelegateSimpleThread> threads_; |
- cc::TaskGraphRunner task_graph_runner_; |
// Lock to exclusively access all the following members that are used to |
// implement the TaskRunner interfaces. |
@@ -99,6 +115,20 @@ class CONTENT_EXPORT RasterWorkerPool |
// Cached vector to avoid allocation when getting the list of complete |
// tasks. |
cc::Task::Vector completed_tasks_; |
+ |
+ // Stores the tasks to be run, sorted by priority. |
+ cc::TaskGraphWorkQueue work_queue_; |
+ |
+ // Condition variable that is waited on by Run() until new tasks are ready to |
+ // run or shutdown starts. |
+ base::ConditionVariable has_ready_to_run_tasks_cv_; |
+ |
+ // Condition variable that is waited on by origin threads until a namespace |
+ // has finished running all associated tasks. |
+ base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_; |
+ |
+ // Set during shutdown. Tells Run() to return when no more tasks are pending. |
+ bool shutdown_; |
}; |
} // namespace content |