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

Unified Diff: content/renderer/raster_worker_pool.h

Issue 1666283002: Reland - Refactor signaling in RWP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: x++ > ++x Created 4 years, 10 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: content/renderer/raster_worker_pool.h
diff --git a/content/renderer/raster_worker_pool.h b/content/renderer/raster_worker_pool.h
index 1d6fc04ca6719ed8fd22f34093b7a35d3c8b4814..dfa325c24c7ccf410c569b397870e9fbdf3b295e 100644
--- a/content/renderer/raster_worker_pool.h
+++ b/content/renderer/raster_worker_pool.h
@@ -48,7 +48,8 @@ class CONTENT_EXPORT RasterWorkerPool : public base::TaskRunner,
// Runs a task from one of the provided categories. Categories listed first
// have higher priority.
- void Run(const std::vector<cc::TaskCategory>& categories);
+ void Run(const std::vector<cc::TaskCategory>& categories,
+ base::ConditionVariable* has_ready_to_run_tasks_cv);
void FlushForTesting();
@@ -75,14 +76,6 @@ class CONTENT_EXPORT RasterWorkerPool : public base::TaskRunner,
class RasterWorkerPoolSequencedTaskRunner;
friend class RasterWorkerPoolSequencedTaskRunner;
- // Runs a task from one of the provided categories. Categories listed first
- // have higher priority. Returns false if there were no tasks to run.
- bool RunTaskWithLockAcquired(const std::vector<cc::TaskCategory>& categories);
-
- // Run next task for the given category. Caller must acquire |lock_| prior to
- // calling this function and make sure at least one task is ready to run.
- void RunTaskInCategoryWithLockAcquired(cc::TaskCategory category);
-
// Simple Task for the TaskGraphRunner that wraps a closure.
// This class is used to schedule TaskRunner tasks on the
// |task_graph_runner_|.
@@ -107,6 +100,22 @@ class CONTENT_EXPORT RasterWorkerPool : public base::TaskRunner,
void CollectCompletedTasksWithLockAcquired(cc::NamespaceToken token,
cc::Task::Vector* completed_tasks);
+ // Runs a task from one of the provided categories. Categories listed first
+ // have higher priority. Returns false if there were no tasks to run.
+ bool RunTaskWithLockAcquired(const std::vector<cc::TaskCategory>& categories);
+
+ // Run next task for the given category. Caller must acquire |lock_| prior to
+ // calling this function and make sure at least one task is ready to run.
+ void RunTaskInCategoryWithLockAcquired(cc::TaskCategory category);
+
+ // Helper function which signals worker threads if tasks are ready to run.
+ void SignalHasReadyToRunTasksWithLockAcquired();
+
+ // Determines if we should run a new task for the given category. This factors
+ // in whether a task is available and whether the count of running tasks is
+ // low enough to start a new one.
+ bool ShouldRunTaskForCategoryWithLockAcquired(cc::TaskCategory category);
+
// The actual threads where work is done.
std::vector<scoped_ptr<base::SimpleThread>> threads_;
@@ -124,9 +133,9 @@ class CONTENT_EXPORT RasterWorkerPool : public base::TaskRunner,
// Cached vector to avoid allocation when getting the list of complete
// tasks.
cc::Task::Vector completed_tasks_;
- // 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 variables for foreground and background tasks.
+ base::ConditionVariable has_ready_to_run_foreground_tasks_cv_;
+ base::ConditionVariable has_ready_to_run_background_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_;

Powered by Google App Engine
This is Rietveld 408576698