Compare commits
No commits in common. "dev" and "v0.5" have entirely different histories.
@ -38,7 +38,11 @@ map<K, uint64_t> Metrics<K>::get_data() const {
|
|||||||
|
|
||||||
template<typename K>
|
template<typename K>
|
||||||
map<K, uint64_t> Metrics<K>::get_data_and_clear() {
|
map<K, uint64_t> Metrics<K>::get_data_and_clear() {
|
||||||
map<K, uint64_t> data = get_data();
|
map<K, uint64_t> data;
|
||||||
|
{
|
||||||
|
shared_lock<shared_mutex> lock(mtx);
|
||||||
|
auto data = get_data();
|
||||||
|
}
|
||||||
clear();
|
clear();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -53,10 +57,9 @@ template<typename K>
|
|||||||
Metrics<K>& Metrics<K>::operator++(int n) {
|
Metrics<K>& Metrics<K>::operator++(int n) {
|
||||||
shared_lock<shared_mutex> lock(mtx);
|
shared_lock<shared_mutex> lock(mtx);
|
||||||
// Increment all counters by n as an example
|
// Increment all counters by n as an example
|
||||||
// for (auto& counter : counters) {
|
for (auto& counter : counters) {
|
||||||
// counter.second.fetch_add(n, memory_order_relaxed);
|
counter.second.fetch_add(n, memory_order_relaxed);
|
||||||
// }
|
}
|
||||||
n++;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,11 +65,7 @@ int main() {
|
|||||||
// map<string, uint64_t> MyStats = {{"access", 3},{ "error", 0}};
|
// map<string, uint64_t> MyStats = {{"access", 3},{ "error", 0}};
|
||||||
// stats.set(MyStats);
|
// stats.set(MyStats);
|
||||||
// // get and clear all counters
|
// // get and clear all counters
|
||||||
auto dataWithClear = metrika.get_data_and_clear();
|
// auto dataWithClear = stats.get_data_and_clear();
|
||||||
|
|
||||||
for (auto& [key, value] : dataWithClear) {
|
|
||||||
cout << "Log analitic " << key << ", value: " << value << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user