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

Side by Side Diff: trunk/src/cc/resources/raster_worker_pool.h

Issue 16178002: Revert 202363 "cc: Cancel and re-prioritize worker pool tasks." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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
8 #include "cc/base/worker_pool.h" 10 #include "cc/base/worker_pool.h"
9 11
10 namespace cc { 12 namespace cc {
11 class PicturePileImpl; 13 class PicturePileImpl;
12 14
13 // A worker thread pool that runs raster tasks. 15 // A worker thread pool that runs raster tasks.
14 class CC_EXPORT RasterWorkerPool : public WorkerPool { 16 class CC_EXPORT RasterWorkerPool : public WorkerPool {
15 public: 17 public:
16 class Task { 18 typedef base::Callback<void(PicturePileImpl* picture_pile)> RasterCallback;
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 };
65 19
66 virtual ~RasterWorkerPool(); 20 virtual ~RasterWorkerPool();
67 21
68 static scoped_ptr<RasterWorkerPool> Create(size_t num_threads) { 22 static scoped_ptr<RasterWorkerPool> Create(size_t num_threads) {
69 return make_scoped_ptr(new RasterWorkerPool(num_threads)); 23 return make_scoped_ptr(new RasterWorkerPool(num_threads));
70 } 24 }
71 25
72 // Tells the worker pool to shutdown after canceling all previously 26 void PostRasterTaskAndReply(PicturePileImpl* picture_pile,
73 // scheduled tasks. Reply callbacks are still guaranteed to run. 27 const RasterCallback& task,
74 virtual void Shutdown() OVERRIDE; 28 const base::Closure& reply);
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);
82 29
83 private: 30 private:
84 explicit RasterWorkerPool(size_t num_threads); 31 explicit RasterWorkerPool(size_t num_threads);
85 32
86 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPool); 33 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPool);
87 }; 34 };
88 35
89 } // namespace cc 36 } // namespace cc
90 37
91 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ 38 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « trunk/src/cc/resources/managed_tile_state.h ('k') | trunk/src/cc/resources/raster_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698