Files
android/libwvdrmengine/cdm/metrics/src/event_metric.cpp
Rahul Frias 0e28104cff Change from custom Lock to std::mutex.
[ Merge of http://go/wvgerrit/67884 ]

Now that we can use C++11, we should use the cross-platform std::mutex
type, not the custom pthread version.

Bug: 111850982
Test: WV unit/integration tests
Change-Id: If2fde2836826c5184609e6b1f3a6511206bd4594
2018-12-13 11:55:54 -08:00

38 lines
881 B
C++

// Copyright 2017 Google Inc. All Rights Reserved.
//
// This file contains implementations for the BaseEventMetric.
#include "event_metric.h"
using ::google::protobuf::RepeatedPtrField;
namespace wvcdm {
namespace metrics {
BaseEventMetric::~BaseEventMetric() {
std::unique_lock<std::mutex> lock(internal_lock_);
for (std::map<std::string, Distribution *>::iterator it = value_map_.begin();
it != value_map_.end(); it++) {
delete it->second;
}
}
void BaseEventMetric::Record(const std::string &key, double value) {
std::unique_lock<std::mutex> lock(internal_lock_);
Distribution *distribution;
if (value_map_.find(key) == value_map_.end()) {
distribution = new Distribution();
value_map_[key] = distribution;
} else {
distribution = value_map_[key];
}
distribution->Record(value);
}
} // namespace metrics
} // namespace wvcdm