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

Unified Diff: cc/resources/raster_worker_pool.h

Issue 14689004: Re-land: cc: Cancel and re-prioritize worker pool tasks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added support for dependencies and tests. Created 7 years, 7 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/resources/raster_worker_pool.h
diff --git a/cc/resources/raster_worker_pool.h b/cc/resources/raster_worker_pool.h
index 76d0497376ff893b50a991ca20cd1182d0d9ca2a..3672af1df7af52b07f99c4c4048fef141059ee05 100644
--- a/cc/resources/raster_worker_pool.h
+++ b/cc/resources/raster_worker_pool.h
@@ -5,8 +5,6 @@
#ifndef CC_RESOURCES_RASTER_WORKER_POOL_H_
#define CC_RESOURCES_RASTER_WORKER_POOL_H_
-#include <string>
-
#include "cc/base/worker_pool.h"
namespace cc {
@@ -15,7 +13,48 @@ class PicturePileImpl;
// A worker thread pool that runs raster tasks.
class CC_EXPORT RasterWorkerPool : public WorkerPool {
public:
- typedef base::Callback<void(PicturePileImpl* picture_pile)> RasterCallback;
+ class Task {
+ public:
+ typedef base::Callback<void(bool)> Reply;
+
+ class Schedule {
+ public:
+ Schedule();
+ ~Schedule();
+
+ void Append(const Task& task);
+ void AppendWithDependencies(const Task& task, Schedule* dependencies);
+
+ private:
+ friend class RasterWorkerPool;
+
+ internal::WorkerPoolTaskGraph task_graph_;
+ };
+
+ Task();
+ Task(const base::Closure& callback, const Reply& reply);
+ ~Task();
+
+ // Returns true if Task is null (doesn't refer to anything).
+ bool is_null() const { return !internal_; }
+
+ // Returns the Task into an uninitialized state.
+ void Reset();
+
+ protected:
+ explicit Task(scoped_refptr<internal::WorkerPoolTask> internal);
+
+ scoped_refptr<internal::WorkerPoolTask> internal_;
+ };
+
+ class PictureTask : public Task {
+ public:
+ typedef base::Callback<void(PicturePileImpl*)> Callback;
+
+ PictureTask(PicturePileImpl* picture_pile,
+ const Callback& callback,
+ const Reply& reply);
+ };
virtual ~RasterWorkerPool();
@@ -23,9 +62,16 @@ class CC_EXPORT RasterWorkerPool : public WorkerPool {
return make_scoped_ptr(new RasterWorkerPool(num_threads));
}
- void PostRasterTaskAndReply(PicturePileImpl* picture_pile,
- const RasterCallback& task,
- const base::Closure& reply);
+ // Tells the worker pool to shutdown after canceling all previously
+ // scheduled tasks. Reply callbacks are still guaranteed to run.
+ virtual void Shutdown() OVERRIDE;
+
+ // Schedule running of tasks in |schedule|. All tasks previously
+ // scheduled but not present in |schedule| will be canceled. Once
+ // scheduled, reply callbacks are guaranteed to run for all tasks even
+ // if they later get canceled by another call to ScheduleTasks(). This
+ // consumed all tasks and queue will be empty when function returns.
+ void ScheduleTasks(Task::Schedule* schedule);
private:
explicit RasterWorkerPool(size_t num_threads);

Powered by Google App Engine
This is Rietveld 408576698