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

Unified Diff: base/debug/activity_analyzer_unittest.cc

Issue 2249683003: Fix some TSAN problems in Activity Tracker/Analyzer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed compile problem Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/debug/activity_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/activity_analyzer_unittest.cc
diff --git a/base/debug/activity_analyzer_unittest.cc b/base/debug/activity_analyzer_unittest.cc
index ff656f60ea8fa9f971291649729aa547d1b7f6cb..6fb6b3f436089b791f4200cee07b43a2e1729639 100644
--- a/base/debug/activity_analyzer_unittest.cc
+++ b/base/debug/activity_analyzer_unittest.cc
@@ -4,6 +4,7 @@
#include "base/debug/activity_analyzer.h"
+#include <atomic>
#include <memory>
#include "base/bind.h"
@@ -90,6 +91,8 @@ class SimpleActivityThread : public SimpleThread {
source_(source),
activity_(activity),
data_(data),
+ ready_(false),
+ exit_(false),
exit_condition_(&lock_) {}
~SimpleActivityThread() override {}
@@ -101,8 +104,8 @@ class SimpleActivityThread : public SimpleThread {
{
AutoLock auto_lock(lock_);
- ready_ = true;
- while (!exit_)
+ ready_.store(true, std::memory_order_relaxed);
+ while (!exit_.load(std::memory_order_relaxed))
exit_condition_.Wait();
}
@@ -113,12 +116,12 @@ class SimpleActivityThread : public SimpleThread {
void Exit() {
AutoLock auto_lock(lock_);
- exit_ = true;
+ exit_.store(true, std::memory_order_relaxed);
exit_condition_.Signal();
}
void WaitReady() {
- SPIN_FOR_1_SECOND_OR_UNTIL_TRUE(ready_);
+ SPIN_FOR_1_SECOND_OR_UNTIL_TRUE(ready_.load(std::memory_order_relaxed));
Alexander Potapenko 2016/10/14 10:07:33 You're waiting for another thread here, but do not
}
private:
@@ -126,8 +129,8 @@ class SimpleActivityThread : public SimpleThread {
Activity::Type activity_;
ActivityData data_;
- bool ready_ = false;
- bool exit_ = false;
+ std::atomic<bool> ready_;
+ std::atomic<bool> exit_;
Lock lock_;
ConditionVariable exit_condition_;
« no previous file with comments | « no previous file | base/debug/activity_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698