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

Side by Side Diff: base/threading/sequenced_worker_pool_unittest.cc

Issue 9522009: Move tsan suppression for SequencedWorkerPool to benign section (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « no previous file | tools/valgrind/tsan/suppressions.txt » ('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) 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 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/synchronization/condition_variable.h" 9 #include "base/synchronization/condition_variable.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 const size_t kNumTasks = 20; 261 const size_t kNumTasks = 20;
262 for (size_t i = 1; i < kNumTasks; i++) { 262 for (size_t i = 1; i < kNumTasks; i++) {
263 pool()->PostWorkerTask(FROM_HERE, 263 pool()->PostWorkerTask(FROM_HERE,
264 base::Bind(&TestTracker::FastTask, tracker(), i)); 264 base::Bind(&TestTracker::FastTask, tracker(), i));
265 } 265 }
266 266
267 std::vector<int> result = tracker()->WaitUntilTasksComplete(kNumTasks); 267 std::vector<int> result = tracker()->WaitUntilTasksComplete(kNumTasks);
268 EXPECT_EQ(kNumTasks, result.size()); 268 EXPECT_EQ(kNumTasks, result.size());
269 } 269 }
270 270
271 // Tests that posting a bunch of tasks (many more than the number of
272 // worker threads) to two pools simultaneously runs them all twice.
273 // This test is meant to shake out any concurrency issues between
274 // pools (like histograms).
275 TEST_F(SequencedWorkerPoolTest, LotsOfTasksTwoPools) {
276 scoped_refptr<SequencedWorkerPool> pool1(
277 new SequencedWorkerPool(kNumWorkerThreads, "test1"));
278 scoped_refptr<SequencedWorkerPool> pool2(
279 new SequencedWorkerPool(kNumWorkerThreads, "test2"));
280
281 base::Closure slow_task = base::Bind(&TestTracker::SlowTask, tracker(), 0);
282 pool1->PostWorkerTask(FROM_HERE, slow_task);
283 pool2->PostWorkerTask(FROM_HERE, slow_task);
284
285 const size_t kNumTasks = 20;
286 for (size_t i = 1; i < kNumTasks; i++) {
287 base::Closure fast_task =
288 base::Bind(&TestTracker::FastTask, tracker(), i);
289 pool1->PostWorkerTask(FROM_HERE, fast_task);
290 pool2->PostWorkerTask(FROM_HERE, fast_task);
291 }
292
293 std::vector<int> result =
294 tracker()->WaitUntilTasksComplete(2*kNumTasks);
295 EXPECT_EQ(2*kNumTasks, result.size());
296 }
297
271 // Test that tasks with the same sequence token are executed in order but don't 298 // Test that tasks with the same sequence token are executed in order but don't
272 // affect other tasks. 299 // affect other tasks.
273 TEST_F(SequencedWorkerPoolTest, Sequence) { 300 TEST_F(SequencedWorkerPoolTest, Sequence) {
274 // Fill all the worker threads except one. 301 // Fill all the worker threads except one.
275 const size_t kNumBackgroundTasks = kNumWorkerThreads - 1; 302 const size_t kNumBackgroundTasks = kNumWorkerThreads - 1;
276 ThreadBlocker background_blocker; 303 ThreadBlocker background_blocker;
277 for (size_t i = 0; i < kNumBackgroundTasks; i++) { 304 for (size_t i = 0; i < kNumBackgroundTasks; i++) {
278 pool()->PostWorkerTask(FROM_HERE, 305 pool()->PostWorkerTask(FROM_HERE,
279 base::Bind(&TestTracker::BlockTask, 306 base::Bind(&TestTracker::BlockTask,
280 tracker(), i, &background_blocker)); 307 tracker(), i, &background_blocker));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 FROM_HERE, base::Bind(&TestTracker::FastTask, tracker(), 0), 424 FROM_HERE, base::Bind(&TestTracker::FastTask, tracker(), 0),
398 SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)); 425 SequencedWorkerPool::CONTINUE_ON_SHUTDOWN));
399 426
400 // Continue the background thread and make sure the task can complete. 427 // Continue the background thread and make sure the task can complete.
401 blocker.Unblock(1); 428 blocker.Unblock(1);
402 std::vector<int> result = tracker()->WaitUntilTasksComplete(1); 429 std::vector<int> result = tracker()->WaitUntilTasksComplete(1);
403 EXPECT_EQ(1u, result.size()); 430 EXPECT_EQ(1u, result.size());
404 } 431 }
405 432
406 } // namespace base 433 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/tsan/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698