aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarkady-e1ppa <arkady-e1ppa@yandex-team.com>2023-12-14 11:22:35 +0300
committerarkady-e1ppa <arkady-e1ppa@yandex-team.com>2023-12-14 12:20:28 +0300
commitee2eaafb0dea43ffcd65a7ff2d80c38fbb5d63cc (patch)
tree9c7a4c9db5d9b6327500b580547e3aa25371f2b1
parent43dc05a0db743e0c219e92c4ef5a8c0bf5bb82e7 (diff)
downloadydb-ee2eaafb0dea43ffcd65a7ff2d80c38fbb5d63cc.tar.gz
Move ApplyJitter impl to inl file
Move jitter impl to inl file
-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 0000000000..941fd92ada
--- /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 7d3935b0d6..39c5b8f82e 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_