Browse Source

Make Random::setSeedRandomly() globalSeed atomic to fix a data race when multiple threads create a Random object

tags/2021-05-28
ed 6 years ago
parent
commit
bd916b68e1
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      modules/juce_core/maths/juce_Random.cpp

+ 1
- 1
modules/juce_core/maths/juce_Random.cpp View File

@@ -58,7 +58,7 @@ void Random::combineSeed (const int64 seedValue) noexcept
void Random::setSeedRandomly()
{
static int64 globalSeed = 0;
static std::atomic<int64> globalSeed { 0 };
combineSeed (globalSeed ^ (int64) (pointer_sized_int) this);
combineSeed (Time::getMillisecondCounter());


Loading…
Cancel
Save