1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

integrating the existing state of TON Storage / TON Payments / CPS Fift development branches

This commit is contained in:
ton 2020-05-27 22:10:46 +04:00
parent 040df63c98
commit 4e2624459b
153 changed files with 10760 additions and 1695 deletions

View file

@ -38,6 +38,13 @@ class ThreadSafeMultiCounter {
tls_.for_each([&](auto &value) { res += value[index].load(); });
return res;
}
void clear() {
tls_.for_each([&](auto &value) {
for (auto &x : value) {
x = 0;
}
});
}
private:
ThreadLocalStorage<std::array<std::atomic<int64>, N>> tls_;
@ -108,6 +115,11 @@ class NamedThreadSafeCounter {
}
}
void clear() {
std::unique_lock<std::mutex> guard(mutex_);
counter_.clear();
}
friend StringBuilder &operator<<(StringBuilder &sb, const NamedThreadSafeCounter &counter) {
counter.for_each([&sb](Slice name, int64 cnt) { sb << name << ": " << cnt << "\n"; });
return sb;