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

Side by Side Diff: base/threading/sequenced_worker_pool.h

Issue 9651026: Clean up condition variable usage in SequencedWorkerPool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 BASE_THREADING_SEQUENCED_WORKER_POOL_H_ 5 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_H_
6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_H_ 6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <string> 10 #include <string>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 const Closure& task, 207 const Closure& task,
208 TimeDelta delay) OVERRIDE; 208 TimeDelta delay) OVERRIDE;
209 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; 209 virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
210 210
211 // Blocks until all pending tasks are complete. This should only be called in 211 // Blocks until all pending tasks are complete. This should only be called in
212 // unit tests when you want to validate something that should have happened. 212 // unit tests when you want to validate something that should have happened.
213 // 213 //
214 // Note that calling this will not prevent other threads from posting work to 214 // Note that calling this will not prevent other threads from posting work to
215 // the queue while the calling thread is waiting on Flush(). In this case, 215 // the queue while the calling thread is waiting on Flush(). In this case,
216 // Flush will return only when there's no more work in the queue. Normally, 216 // Flush will return only when there's no more work in the queue. Normally,
217 // this doesn't come up sine in a test, all the work is being posted from 217 // this doesn't come up since in a test, all the work is being posted from
218 // the main thread. 218 // the main thread.
219 void FlushForTesting(); 219 void FlushForTesting();
220 220
221 // Spuriously signal that there is work to be done.
222 void TriggerSpuriousWorkSignalForTesting();
223
224 // Get the number of times the work signal has been triggered.
225 int GetWorkSignalCountForTesting() const;
226
221 // Implements the worker pool shutdown. This should be called during app 227 // Implements the worker pool shutdown. This should be called during app
222 // shutdown, and will discard/join with appropriate tasks before returning. 228 // shutdown, and will discard/join with appropriate tasks before returning.
223 // After this call, subsequent calls to post tasks will fail. 229 // After this call, subsequent calls to post tasks will fail.
224 void Shutdown(); 230 void Shutdown();
225 231
226 // Called by tests to set the testing observer. This is NULL by default 232 // Called by tests to set the testing observer. This is NULL by default
227 // and ownership of the pointer is kept with the caller. 233 // and ownership of the pointer is kept with the caller.
228 void SetTestingObserver(TestingObserver* observer); 234 void SetTestingObserver(TestingObserver* observer);
229 235
230 protected: 236 protected:
(...skipping 13 matching lines...) Expand all
244 // Avoid pulling in too many headers by putting (almost) everything 250 // Avoid pulling in too many headers by putting (almost) everything
245 // into |inner_|. 251 // into |inner_|.
246 const scoped_ptr<Inner> inner_; 252 const scoped_ptr<Inner> inner_;
247 253
248 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); 254 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool);
249 }; 255 };
250 256
251 } // namespace base 257 } // namespace base
252 258
253 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ 259 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool.cc » ('j') | base/threading/sequenced_worker_pool.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698