Chromium Code Reviews| Index: base/metrics/histogram_samples.cc |
| =================================================================== |
| --- base/metrics/histogram_samples.cc (revision 242425) |
| +++ 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 = |
|
jar (doing other things)
2013/12/24 18:00:55
<sigh>... this is also seemingly atomic... which i
Alexander Potapenko
2013/12/25 09:08:31
I think making accesses to old_redundant_count ato
jar (doing other things)
2013/12/25 20:12:01
Quoting from line 19 of atomics.h documentation ab
Alexander Potapenko
2013/12/26 09:26:10
Correct, I've missed that.
|
| + 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() {} |