fix: Use UniformRandomGenerator class to prevent threading issue (#2165)

This commit is contained in:
Ayaz Salikhov
2025-05-29 19:59:40 +01:00
committed by GitHub
parent 9b69da7f91
commit 57b8ff1c49
13 changed files with 174 additions and 48 deletions

View File

@@ -25,12 +25,20 @@
namespace util {
void
Random::setSeed(size_t seed)
MTRandomGenerator::MTRandomGenerator() : generator_{std::chrono::system_clock::now().time_since_epoch().count()}
{
generator.seed(seed);
}
std::mt19937_64 Random::generator{std::chrono::system_clock::now().time_since_epoch().count()};
size_t
MTRandomGenerator::uniform(size_t min, size_t max)
{
return uniformImpl(min, max);
}
void
MTRandomGenerator::setSeed(SeedType seed)
{
generator_.seed(seed);
}
} // namespace util