summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Fung <stevefung@google.com>2016-08-10 21:08:56 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-08-10 21:08:56 +0000
commit1753b07fea061809f8829807024e34ab0e79d690 (patch)
tree9817570a42456db836293dd6e2aa636b96b373ac
parentc9dc97b56cc5c4f2b2a35d3dafbe85efa1165f5d (diff)
parenta8252e176a46329501ef787b6423c70d6d178458 (diff)
downloadlibchrome-1753b07fea061809f8829807024e34ab0e79d690.tar.gz
Revert "Fix a race condition in persistent memory allocator unit test" am: 7de8dfb2b9 am: b4dd8aa002
am: a8252e176a Change-Id: I7c27c87a1e2cc392a3f4e722ed1c772ec7a01d37
-rw-r--r--base/metrics/persistent_memory_allocator_unittest.cc29
1 files changed, 8 insertions, 21 deletions
diff --git a/base/metrics/persistent_memory_allocator_unittest.cc b/base/metrics/persistent_memory_allocator_unittest.cc
index a0fd5f8ebe..64333389a1 100644
--- a/base/metrics/persistent_memory_allocator_unittest.cc
+++ b/base/metrics/persistent_memory_allocator_unittest.cc
@@ -320,14 +320,12 @@ class CounterThread : public SimpleThread {
CounterThread(const std::string& name,
PersistentMemoryAllocator::Iterator* iterator,
Lock* lock,
- ConditionVariable* condition,
- bool* wake_up)
+ ConditionVariable* condition)
: SimpleThread(name, Options()),
iterator_(iterator),
lock_(lock),
condition_(condition),
- count_(0),
- wake_up_(wake_up) {}
+ count_(0) {}
void Run() override {
// Wait so all threads can start at approximately the same time.
@@ -335,9 +333,7 @@ class CounterThread : public SimpleThread {
// releases the next, etc., etc.
{
AutoLock autolock(*lock_);
- while (!*wake_up_) {
- condition_->Wait();
- }
+ condition_->Wait();
condition_->Signal();
}
@@ -354,7 +350,6 @@ class CounterThread : public SimpleThread {
Lock* lock_;
ConditionVariable* condition_;
unsigned count_;
- bool* wake_up_;
};
// Ensure that parallel iteration returns the same number of objects as
@@ -378,13 +373,12 @@ TEST_F(PersistentMemoryAllocatorTest, IteratorParallelismTest) {
PersistentMemoryAllocator::Iterator iter(allocator_.get());
Lock lock;
ConditionVariable condition(&lock);
- bool wake_up = false;
- CounterThread t1("t1", &iter, &lock, &condition, &wake_up);
- CounterThread t2("t2", &iter, &lock, &condition, &wake_up);
- CounterThread t3("t3", &iter, &lock, &condition, &wake_up);
- CounterThread t4("t4", &iter, &lock, &condition, &wake_up);
- CounterThread t5("t5", &iter, &lock, &condition, &wake_up);
+ CounterThread t1("t1", &iter, &lock, &condition);
+ CounterThread t2("t2", &iter, &lock, &condition);
+ CounterThread t3("t3", &iter, &lock, &condition);
+ CounterThread t4("t4", &iter, &lock, &condition);
+ CounterThread t5("t5", &iter, &lock, &condition);
t1.Start();
t2.Start();
@@ -392,13 +386,6 @@ TEST_F(PersistentMemoryAllocatorTest, IteratorParallelismTest) {
t4.Start();
t5.Start();
- // Avoid a race condition with the threads calling Wait() and sending
- // the condition.Signal().
- {
- AutoLock autolock(lock);
- wake_up = true;
- }
-
// This will release all the waiting threads.
condition.Signal();