summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yt/yt/core/misc/jitter-inl.h28
-rw-r--r--yt/yt/core/misc/jitter.h17
2 files changed, 33 insertions, 12 deletions
diff --git a/yt/yt/core/misc/jitter-inl.h b/yt/yt/core/misc/jitter-inl.h
new file mode 100644
index 00000000000..941fd92ada9
--- /dev/null
+++ b/yt/yt/core/misc/jitter-inl.h
@@ -0,0 +1,28 @@
+#ifndef JITTER_INL_H_
+#error "Direct inclusion of this file is not allowed, include jitter.h"
+// For the sake of sane code completion.
+#include "jitter.h"
+#endif
+
+namespace NYT {
+
+////////////////////////////////////////////////////////////////////////////////
+
+template <CScalable<double> TValue, class TRandomGenerator>
+ requires std::is_invocable_r<double, TRandomGenerator>::value
+constexpr inline TValue ApplyJitter(TValue average, double jitter, const TRandomGenerator& randomGenerator)
+{
+ YT_VERIFY(jitter >= 0 && jitter <= 1);
+
+ double rnd = randomGenerator();
+
+ YT_VERIFY(std::abs(rnd) <= 1);
+
+ double multiplier = static_cast<double>(1) + jitter * rnd;
+
+ return average * multiplier;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace NYT
diff --git a/yt/yt/core/misc/jitter.h b/yt/yt/core/misc/jitter.h
index 7d3935b0d63..39c5b8f82ec 100644
--- a/yt/yt/core/misc/jitter.h
+++ b/yt/yt/core/misc/jitter.h
@@ -10,19 +10,12 @@ namespace NYT {
//! Will crash otherwise
template <CScalable<double> TValue, class TRandomGenerator>
requires std::is_invocable_r<double, TRandomGenerator>::value
-constexpr inline TValue ApplyJitter(TValue average, double jitter, const TRandomGenerator& randomGenerator)
-{
- YT_VERIFY(jitter >= 0 && jitter <= 1);
-
- double rnd = randomGenerator();
-
- YT_VERIFY(std::abs(rnd) <= 1);
-
- double multiplier = static_cast<double>(1) + jitter * rnd;
-
- return average * multiplier;
-}
+constexpr inline TValue ApplyJitter(TValue average, double jitter, const TRandomGenerator& randomGenerator);
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
+
+#define JITTER_INL_H_
+#include "jitter-inl.h"
+#undef JITTER_INL_H_