From c027792d0f00b88ded967b493bc020bb2f9b5b73 Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Tue, 4 Jun 2019 13:40:48 -0700 Subject: [PATCH] Make the default seed of the generator returned by deterministicRandom() random. This means that the random number sequence won't be deterministic unless you set a seed. --- flow/IRandom.h | 2 ++ flow/flow.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/flow/IRandom.h b/flow/IRandom.h index 7201404a32..0a1716e3f9 100644 --- a/flow/IRandom.h +++ b/flow/IRandom.h @@ -127,6 +127,8 @@ void setThreadLocalDeterministicRandomSeed(uint32_t seed); // Returns the random number generator that can be seeded. This generator should only // be used in contexts where the choice to call it is deterministic. +// +// This generator is only deterministic if given a seed using setThreadLocalDeterministicRandomSeed Reference deterministicRandom(); // A random number generator that cannot be manually seeded and may be called in diff --git a/flow/flow.cpp b/flow/flow.cpp index 98a2e484f4..55b5e637e7 100644 --- a/flow/flow.cpp +++ b/flow/flow.cpp @@ -37,7 +37,7 @@ void setThreadLocalDeterministicRandomSeed(uint32_t seed) { Reference deterministicRandom() { if(!seededRandom) { - seededRandom = Reference(new DeterministicRandom(1, true)); + seededRandom = Reference(new DeterministicRandom(platform::getRandomSeed(), true)); } return seededRandom; }