Fix data race problem

PiperOrigin-RevId: 485414615
This commit is contained in:
hai007
2022-11-01 14:13:24 -07:00
committed by Copybara-Service
parent 3d812bbf1c
commit 5385dd4d6b
+3 -1
View File
@@ -50,9 +50,11 @@ TEST(PrngTest, NextInt32GeneratesDifferentValues) {
}
TEST(PrngTest, NextInt32AcrossThreads) {
absl::Mutex mutex;
Prng prng;
std::set<int32_t> values;
auto func = [&prng, &values]() {
auto func = [&prng, &values, &mutex]() {
absl::MutexLock lock(&mutex);
auto value = prng.NextInt32();
EXPECT_LE(value, std::numeric_limits<std::int32_t>::max());
EXPECT_GE(value, std::numeric_limits<std::int32_t>::min());