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

Side by Side Diff: base/simple_thread.h

Issue 155022: Fix few trivial Coverity issues, mainly PASS_BY_VALUE. (Closed)
Patch Set: Created 11 years, 5 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 | « base/file_path.cc ('k') | base/tracked_objects.h » ('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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // WARNING: You should probably be using Thread (thread.h) instead. Thread is 5 // WARNING: You should probably be using Thread (thread.h) instead. Thread is
6 // Chrome's message-loop based Thread abstraction, and if you are a 6 // Chrome's message-loop based Thread abstraction, and if you are a
7 // thread running in the browser, there will likely be assumptions 7 // thread running in the browser, there will likely be assumptions
8 // that your thread will have an associated message loop. 8 // that your thread will have an associated message loop.
9 // 9 //
10 // This is a simple thread interface that backs to a native operating system 10 // This is a simple thread interface that backs to a native operating system
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // multi-threaded, but don't want to spawn a thread for each small bit of work. 145 // multi-threaded, but don't want to spawn a thread for each small bit of work.
146 // 146 //
147 // You just call AddWork() to add a delegate to the list of work to be done. 147 // You just call AddWork() to add a delegate to the list of work to be done.
148 // JoinAll() will make sure that all outstanding work is processed, and wait 148 // JoinAll() will make sure that all outstanding work is processed, and wait
149 // for everything to finish. You can reuse a pool, so you can call Start() 149 // for everything to finish. You can reuse a pool, so you can call Start()
150 // again after you've called JoinAll(). 150 // again after you've called JoinAll().
151 class DelegateSimpleThreadPool : public DelegateSimpleThread::Delegate { 151 class DelegateSimpleThreadPool : public DelegateSimpleThread::Delegate {
152 public: 152 public:
153 typedef DelegateSimpleThread::Delegate Delegate; 153 typedef DelegateSimpleThread::Delegate Delegate;
154 154
155 DelegateSimpleThreadPool(const std::string name_prefix, int num_threads) 155 DelegateSimpleThreadPool(const std::string& name_prefix, int num_threads)
156 : name_prefix_(name_prefix), num_threads_(num_threads), 156 : name_prefix_(name_prefix), num_threads_(num_threads),
157 dry_(true, false) { } 157 dry_(true, false) { }
158 ~DelegateSimpleThreadPool(); 158 ~DelegateSimpleThreadPool();
159 159
160 // Start up all of the underlying threads, and start processing work if we 160 // Start up all of the underlying threads, and start processing work if we
161 // have any. 161 // have any.
162 void Start(); 162 void Start();
163 163
164 // Make sure all outstanding work is finished, and wait for and destroy all 164 // Make sure all outstanding work is finished, and wait for and destroy all
165 // of the underlying threads in the pool. 165 // of the underlying threads in the pool.
(...skipping 14 matching lines...) Expand all
180 int num_threads_; 180 int num_threads_;
181 std::vector<DelegateSimpleThread*> threads_; 181 std::vector<DelegateSimpleThread*> threads_;
182 std::queue<Delegate*> delegates_; 182 std::queue<Delegate*> delegates_;
183 Lock lock_; // Locks delegates_ 183 Lock lock_; // Locks delegates_
184 WaitableEvent dry_; // Not signaled when there is no work to do. 184 WaitableEvent dry_; // Not signaled when there is no work to do.
185 }; 185 };
186 186
187 } // namespace base 187 } // namespace base
188 188
189 #endif // BASE_SIMPLE_THREAD_H_ 189 #endif // BASE_SIMPLE_THREAD_H_
OLDNEW
« no previous file with comments | « base/file_path.cc ('k') | base/tracked_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698