*/
#include <folly/SmallLocks.h>
+
+#include <folly/Random.h>
+
#include <cassert>
#include <cstdio>
#include <mutex>
void splock_test() {
const int max = 1000;
- unsigned int seed = (uintptr_t)pthread_self();
+ auto rng = folly::ThreadLocalPRNG();
for (int i = 0; i < max; i++) {
folly::asm_pause();
MSLGuard g(v.lock);
EXPECT_EQ(first, v.ar[i]);
}
- int byte = rand_r(&seed);
+ int byte = folly::Random::rand32(rng);
memset(v.ar, char(byte), sizeof v.ar);
}
}
*/
#include <folly/SpinLock.h>
+#include <folly/Random.h>
+
#include <gtest/gtest.h>
#include <thread>
template <typename LOCK>
void spinlockTestThread(LockedVal<LOCK>* v) {
const int max = 1000;
- unsigned int seed = (uintptr_t)pthread_self();
+ auto rng = folly::ThreadLocalPRNG();
for (int i = 0; i < max; i++) {
folly::asm_pause();
SpinLockGuardImpl<LOCK> g(v->lock);
EXPECT_EQ(first, v->ar[i]);
}
- int byte = rand_r(&seed);
+ int byte = folly::Random::rand32(rng);
memset(v->ar, char(byte), sizeof v->ar);
}
}