diff options
author | sergeyu <sergeyu@chromium.org> | 2015-09-18 12:52:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-18 19:53:11 +0000 |
commit | 6a07d9a158c8cf496200993505d1395dd78277a7 (patch) | |
tree | 607dc700f9aa2ced5880e9cf954935ba24fbce32 /remoting/base | |
parent | d3683425e90a9ed9a3759f193d5e51f74bbc1ca7 (diff) | |
download | chromium_src-6a07d9a158c8cf496200993505d1395dd78277a7.zip chromium_src-6a07d9a158c8cf496200993505d1395dd78277a7.tar.gz chromium_src-6a07d9a158c8cf496200993505d1395dd78277a7.tar.bz2 |
Remove lock from remoting::RunningAverage
The class is always used on the same thread, so it doesn't need to be
thread-safe.
Review URL: https://codereview.chromium.org/1351253002
Cr-Commit-Position: refs/heads/master@{#349746}
Diffstat (limited to 'remoting/base')
-rw-r--r-- | remoting/base/running_average.cc | 9 | ||||
-rw-r--r-- | remoting/base/running_average.h | 13 |
2 files changed, 10 insertions, 12 deletions
diff --git a/remoting/base/running_average.cc b/remoting/base/running_average.cc index 83877dc..5e24c0d 100644 --- a/remoting/base/running_average.cc +++ b/remoting/base/running_average.cc @@ -14,11 +14,10 @@ RunningAverage::RunningAverage(int window_size) DCHECK_GT(window_size, 0); } -RunningAverage::~RunningAverage() { -} +RunningAverage::~RunningAverage() {} -void RunningAverage::Record(int64 value) { - base::AutoLock auto_lock(lock_); +void RunningAverage::Record(int64_t value) { + DCHECK(thread_checker_.CalledOnValidThread()); data_points_.push_back(value); sum_ += value; @@ -30,7 +29,7 @@ void RunningAverage::Record(int64 value) { } double RunningAverage::Average() { - base::AutoLock auto_lock(lock_); + DCHECK(thread_checker_.CalledOnValidThread()); if (data_points_.empty()) return 0; diff --git a/remoting/base/running_average.h b/remoting/base/running_average.h index 633659d..2ed2115 100644 --- a/remoting/base/running_average.h +++ b/remoting/base/running_average.h @@ -8,7 +8,7 @@ #include <deque> #include "base/basictypes.h" -#include "base/synchronization/lock.h" +#include "base/threading/thread_checker.h" namespace remoting { @@ -22,7 +22,7 @@ class RunningAverage { virtual ~RunningAverage(); // Records a point sample. - void Record(int64 value); + void Record(int64_t value); // Returns the average over up to |window_size| of the most recent samples. double Average(); @@ -32,14 +32,13 @@ class RunningAverage { // with the size of |data_points_|. const size_t window_size_; - // Protects |data_points_| and |sum_|. - base::Lock lock_; - // Stores the |window_size| most recently recorded samples. - std::deque<int64> data_points_; + std::deque<int64_t> data_points_; // Holds the sum of the samples in |data_points_|. - int64 sum_; + int64_t sum_; + + base::ThreadChecker thread_checker_; DISALLOW_COPY_AND_ASSIGN(RunningAverage); }; |