CurrentMetrics/Increment: Introduce add()

This commit is contained in:
Azat Khuzhin 2021-01-26 22:21:36 +03:00
parent 017c054a35
commit 70049db143
2 changed files with 7 additions and 2 deletions

View File

@ -100,6 +100,12 @@ namespace CurrentMetrics
amount -= value;
}
void add(Value value = 1)
{
what->fetch_add(value, std::memory_order_relaxed);
amount += value;
}
/// Subtract value before destructor.
void destroy()
{

View File

@ -758,8 +758,7 @@ bool StorageDistributedDirectoryMonitor::addAndSchedule(size_t file_size, size_t
{
std::lock_guard metrics_lock(metrics_mutex);
/// TODO: extend CurrentMetrics::Increment
metric_pending_files.sub(-1);
metric_pending_files.add();
bytes_count += file_size;
++files_count;
}