We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89e79f2 commit 0f454e3Copy full SHA for 0f454e3
core/src/gauge.cc
@@ -17,11 +17,16 @@ void Gauge::Decrement(const double value) { Change(-1.0 * value); }
17
void Gauge::Set(const double value) { value_.store(value); }
18
19
void Gauge::Change(const double value) {
20
- // C++ 20 will add std::atomic::fetch_add support for floating point types
+#if __cpp_lib_atomic_float >= 201711L
21
+ value_.fetch_add(value);
22
+#else
23
+ // Pre-C++ 20 fallback: busy loop (which might be more expansive than using
24
+ // fetch_add).
25
auto current = value_.load();
26
while (!value_.compare_exchange_weak(current, current + value)) {
27
// intentionally empty block
28
}
29
+#endif
30
31
32
void Gauge::SetToCurrentTime() {
0 commit comments