blob: c0334322805d05ead0be51af2ce89bf40377941c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "current_samples.h"
namespace vespalib {
namespace metrics {
using Guard = std::lock_guard<std::mutex>;
void
CurrentSamples::add(Counter::Increment inc)
{
Guard guard(lock);
counterIncrements.add(inc);
}
void
CurrentSamples::sample(Gauge::Measurement value)
{
Guard guard(lock);
gaugeMeasurements.add(value);
}
void
CurrentSamples::extract(CurrentSamples &into)
{
Guard guard(lock);
swap(into.counterIncrements, counterIncrements);
swap(into.gaugeMeasurements, gaugeMeasurements);
}
} // namespace vespalib::metrics
} // namespace vespalib
|