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

Unified Diff: base/metrics/histogram_samples.cc

Issue 116983004: Change some operations touching counts_[] to be atomic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years 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 | « base/metrics/histogram_samples.h ('k') | base/metrics/sample_vector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_samples.cc
===================================================================
--- base/metrics/histogram_samples.cc (revision 242519)
+++ base/metrics/histogram_samples.cc (working copy)
@@ -64,7 +64,10 @@
void HistogramSamples::Add(const HistogramSamples& other) {
sum_ += other.sum();
- redundant_count_ += other.redundant_count();
+ HistogramBase::Count old_redundant_count =
+ subtle::NoBarrier_Load(&redundant_count_);
+ subtle::NoBarrier_Store(&redundant_count_,
+ old_redundant_count + other.redundant_count());
bool success = AddSubtractImpl(other.Iterator().get(), ADD);
DCHECK(success);
}
@@ -76,7 +79,10 @@
if (!iter->ReadInt64(&sum) || !iter->ReadInt(&redundant_count))
return false;
sum_ += sum;
- redundant_count_ += redundant_count;
+ HistogramBase::Count old_redundant_count =
+ subtle::NoBarrier_Load(&redundant_count_);
+ subtle::NoBarrier_Store(&redundant_count_,
+ old_redundant_count + redundant_count);
SampleCountPickleIterator pickle_iter(iter);
return AddSubtractImpl(&pickle_iter, ADD);
@@ -84,13 +90,17 @@
void HistogramSamples::Subtract(const HistogramSamples& other) {
sum_ -= other.sum();
- redundant_count_ -= other.redundant_count();
+ HistogramBase::Count old_redundant_count =
+ subtle::NoBarrier_Load(&redundant_count_);
+ subtle::NoBarrier_Store(&redundant_count_,
+ old_redundant_count - other.redundant_count());
bool success = AddSubtractImpl(other.Iterator().get(), SUBTRACT);
DCHECK(success);
}
bool HistogramSamples::Serialize(Pickle* pickle) const {
- if (!pickle->WriteInt64(sum_) || !pickle->WriteInt(redundant_count_))
+ if (!pickle->WriteInt64(sum_) ||
+ !pickle->WriteInt(subtle::NoBarrier_Load(&redundant_count_)))
return false;
HistogramBase::Sample min;
@@ -113,8 +123,8 @@
}
void HistogramSamples::IncreaseRedundantCount(HistogramBase::Count diff) {
- base::subtle::NoBarrier_Store(&redundant_count_,
- base::subtle::NoBarrier_Load(&redundant_count_) + diff);
+ subtle::NoBarrier_Store(&redundant_count_,
+ subtle::NoBarrier_Load(&redundant_count_) + diff);
}
SampleCountIterator::~SampleCountIterator() {}
« no previous file with comments | « base/metrics/histogram_samples.h ('k') | base/metrics/sample_vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698