Add copy and move constructors to RateStatistics.
Bug: none Change-Id: I589a7f202ee1c4b8c06e8f44aa570c47d066ab72 Reviewed-on: https://webrtc-review.googlesource.com/95647 Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24445}
This commit is contained in:
committed by
Commit Bot
parent
ec4a060a55
commit
40b7050ac6
@ -444,6 +444,7 @@ rtc_source_set("rtc_base_approved_generic") {
|
||||
deps += [
|
||||
"..:webrtc_common",
|
||||
"../api:array_view",
|
||||
"//third_party/abseil-cpp/absl/memory:memory",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -26,6 +27,21 @@ RateStatistics::RateStatistics(int64_t window_size_ms, float scale)
|
||||
max_window_size_ms_(window_size_ms),
|
||||
current_window_size_ms_(max_window_size_ms_) {}
|
||||
|
||||
RateStatistics::RateStatistics(const RateStatistics& other)
|
||||
: accumulated_count_(other.accumulated_count_),
|
||||
num_samples_(other.num_samples_),
|
||||
oldest_time_(other.oldest_time_),
|
||||
oldest_index_(other.oldest_index_),
|
||||
scale_(other.scale_),
|
||||
max_window_size_ms_(other.max_window_size_ms_),
|
||||
current_window_size_ms_(other.current_window_size_ms_) {
|
||||
buckets_ = absl::make_unique<Bucket[]>(other.max_window_size_ms_);
|
||||
std::copy(other.buckets_.get(),
|
||||
other.buckets_.get() + other.max_window_size_ms_, buckets_.get());
|
||||
}
|
||||
|
||||
RateStatistics::RateStatistics(RateStatistics&& other) = default;
|
||||
|
||||
RateStatistics::~RateStatistics() {}
|
||||
|
||||
void RateStatistics::Reset() {
|
||||
|
||||
@ -27,6 +27,11 @@ class RateStatistics {
|
||||
// scale = coefficient to convert counts/ms to desired unit
|
||||
// ex: kBpsScale (8000) for bits/s if count represents bytes.
|
||||
RateStatistics(int64_t max_window_size_ms, float scale);
|
||||
|
||||
RateStatistics(const RateStatistics& other);
|
||||
|
||||
RateStatistics(RateStatistics&& other);
|
||||
|
||||
~RateStatistics();
|
||||
|
||||
// Reset instance to original state.
|
||||
|
||||
Reference in New Issue
Block a user