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

Side by Side Diff: cc/resources/worker_pool.h

Issue 73923003: Shared Raster Worker Threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build Error for Mac, macro conflict, moving setter to WorkerPool. Created 6 years, 11 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
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | cc/resources/worker_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_WORKER_POOL_H_ 5 #ifndef CC_RESOURCES_WORKER_POOL_H_
6 #define CC_RESOURCES_WORKER_POOL_H_ 6 #define CC_RESOURCES_WORKER_POOL_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // A worker thread pool that runs tasks provided by task graph and 98 // A worker thread pool that runs tasks provided by task graph and
99 // guarantees completion of all pending tasks at shutdown. 99 // guarantees completion of all pending tasks at shutdown.
100 class CC_EXPORT WorkerPool { 100 class CC_EXPORT WorkerPool {
101 public: 101 public:
102 virtual ~WorkerPool(); 102 virtual ~WorkerPool();
103 103
104 // Tells the worker pool to shutdown and returns once all pending tasks have 104 // Tells the worker pool to shutdown and returns once all pending tasks have
105 // completed. 105 // completed.
106 virtual void Shutdown(); 106 virtual void Shutdown();
107 107
108 protected: 108 // Sets the number of threads to use for running raster tasks.
109 // Can only be called once prior to GetNumRasterThreads().
110 // Caller is responsible for correct ordering.
111 // TODO(reveman): Move this to RasterWorkerPool: crbug.com/331844
112 static void SetNumRasterThreads(int num_threads);
113
114 // Gets the number of threads to use for running raster tasks.
115 // TODO(reveman): Move this to RasterWorkerPool: crbug.com/331844
116 static int GetNumRasterThreads();
117
109 // A task graph contains a unique set of tasks with edges between 118 // A task graph contains a unique set of tasks with edges between
110 // dependencies pointing in the direction of the dependents. Each task 119 // dependencies pointing in the direction of the dependents. Each task
111 // need to be assigned a unique priority and a run count that matches 120 // need to be assigned a unique priority and a run count that matches
112 // the number of dependencies. 121 // the number of dependencies.
113 typedef base::ScopedPtrHashMap<internal::WorkerPoolTask*, internal::GraphNode> 122 typedef base::ScopedPtrHashMap<internal::WorkerPoolTask*, internal::GraphNode>
114 GraphNodeMap; 123 GraphNodeMap;
115 typedef GraphNodeMap TaskGraph; 124 typedef GraphNodeMap TaskGraph;
125 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector;
116 126
117 WorkerPool(size_t num_threads, const std::string& thread_name_prefix); 127 protected:
128 WorkerPool();
118 129
119 // Schedule running of tasks in |graph|. Any previously scheduled tasks 130 // Schedule running of tasks in |graph|. Any previously scheduled tasks
120 // that are not already running will be canceled. Canceled tasks don't run 131 // that are not already running will be canceled. Canceled tasks don't run
121 // but completion of them is still processed. 132 // but completion of them is still processed.
122 void SetTaskGraph(TaskGraph* graph); 133 void SetTaskGraph(TaskGraph* graph);
123 134
124 // Force a check for completed tasks. 135 // Force a check for completed tasks.
125 void CheckForCompletedWorkerTasks(); 136 void CheckForCompletedWorkerTasks();
126 137
127 private: 138 private:
128 class Inner;
129 friend class Inner;
130
131 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector;
132
133 void ProcessCompletedTasks(const TaskVector& completed_tasks); 139 void ProcessCompletedTasks(const TaskVector& completed_tasks);
134 140
135 bool in_dispatch_completion_callbacks_; 141 bool in_dispatch_completion_callbacks_;
136
137 // Hide the gory details of the worker pool in |inner_|.
138 const scoped_ptr<Inner> inner_;
139 }; 142 };
140 143
141 } // namespace cc 144 } // namespace cc
142 145
143 #endif // CC_RESOURCES_WORKER_POOL_H_ 146 #endif // CC_RESOURCES_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | cc/resources/worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698