Browse Source

Use 64-bit atomic for thread counter in random seed initialization.

tags/v2.0.0
Andrew Belt 5 years ago
parent
commit
f6eb33a235
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      src/random.cpp

+ 2
- 1
src/random.cpp View File

@@ -2,6 +2,7 @@
#include <math.hpp>
#include <time.h>
#include <sys/time.h>
#include <atomic>


namespace rack {
@@ -12,7 +13,7 @@ namespace random {
// from http://xoroshiro.di.unimi.it/xoroshiro128plus.c

thread_local uint64_t xoroshiro128plus_state[2];
static int threadCounter = 0;
static std::atomic<uint64_t> threadCounter {0};

static uint64_t rotl(const uint64_t x, int k) {
return (x << k) | (x >> (64 - k));


Loading…
Cancel
Save