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

Side by Side 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: keep image cache check 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_RESOURCES_RASTER_WORKER_POOL_H_ 5 #ifndef CC_RESOURCES_RASTER_WORKER_POOL_H_
6 #define CC_RESOURCES_RASTER_WORKER_POOL_H_ 6 #define CC_RESOURCES_RASTER_WORKER_POOL_H_
7 7
8 #include <string>
9
10 #include "cc/base/worker_pool.h" 8 #include "cc/base/worker_pool.h"
11 9
12 namespace cc { 10 namespace cc {
13 class PicturePileImpl; 11 class PicturePileImpl;
14 12
15 // A worker thread pool that runs raster tasks. 13 // A worker thread pool that runs raster tasks.
16 class CC_EXPORT RasterWorkerPool : public WorkerPool { 14 class CC_EXPORT RasterWorkerPool : public WorkerPool {
17 public: 15 public:
18 typedef base::Callback<void(PicturePileImpl* picture_pile)> RasterCallback; 16 class Task {
reveman 2013/05/23 22:21:32 FYI, added this class instead of exposing the inte
17 public:
18 typedef base::Callback<void(bool)> Reply;
19
20 // Highest priority task first. Order of execution is not guaranteed.
21 class Queue {
22 public:
23 Queue();
24 ~Queue();
25
26 bool empty() const { return tasks_.empty(); }
27
28 // Add task to the back of the queue.
29 void Append(const Task& task);
30
31 private:
32 friend class RasterWorkerPool;
33
34 internal::WorkerPoolTask::TaskVector tasks_;
35 };
36
37 Task();
38 Task(const base::Closure& callback, const Reply& reply);
39 explicit Task(Queue* dependencies);
40 ~Task();
41
42 // Returns true if Task is null (doesn't refer to anything).
43 bool is_null() const { return !internal_; }
44
45 // Returns the Task into an uninitialized state.
46 void Reset();
47
48 protected:
49 friend class RasterWorkerPool;
50
51 explicit Task(scoped_refptr<internal::WorkerPoolTask> internal);
52
53 scoped_refptr<internal::WorkerPoolTask> internal_;
54 };
55
56 class PictureTask : public Task {
57 public:
58 typedef base::Callback<void(PicturePileImpl*)> Callback;
59
60 PictureTask(PicturePileImpl* picture_pile,
61 const Callback& callback,
62 const Reply& reply,
63 Queue* dependencies);
64 };
19 65
20 virtual ~RasterWorkerPool(); 66 virtual ~RasterWorkerPool();
21 67
22 static scoped_ptr<RasterWorkerPool> Create(size_t num_threads) { 68 static scoped_ptr<RasterWorkerPool> Create(size_t num_threads) {
23 return make_scoped_ptr(new RasterWorkerPool(num_threads)); 69 return make_scoped_ptr(new RasterWorkerPool(num_threads));
24 } 70 }
25 71
26 void PostRasterTaskAndReply(PicturePileImpl* picture_pile, 72 // Tells the worker pool to shutdown after canceling all previously
27 const RasterCallback& task, 73 // scheduled tasks. Reply callbacks are still guaranteed to run.
28 const base::Closure& reply); 74 virtual void Shutdown() OVERRIDE;
75
76 // Schedule running of |root| task and all its dependencies. Tasks
77 // previously scheduled but no longer needed to run |root| will be
78 // canceled unless already running. Once scheduled, reply callbacks
79 // are guaranteed to run for all tasks even if they later get
80 // canceled by another call to ScheduleTasks().
81 void ScheduleTasks(Task* root);
29 82
30 private: 83 private:
31 explicit RasterWorkerPool(size_t num_threads); 84 explicit RasterWorkerPool(size_t num_threads);
32 85
33 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPool); 86 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPool);
34 }; 87 };
35 88
36 } // namespace cc 89 } // namespace cc
37 90
38 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ 91 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698