aggregator: fix `doEagerInitVia`
[folly.git] / folly / test / SynchronizedTestLib-inl.h
index aa2e3dcbf111e235ee58c918802a36bb78d25b4a..ef4045c8c4242b8d4e0e511ac7f627cc138f1ad4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <folly/Synchronized.h>
 
 
-static const auto seed = folly::randomNumberSeed();
-typedef std::mt19937 RandomT;
-static RandomT rng(seed);
+inline std::mt19937& getRNG() {
+  static const auto seed = folly::randomNumberSeed();
+  static std::mt19937 rng(seed);
+  return rng;
+}
 
 template <class Integral1, class Integral2>
 Integral2 random(Integral1 low, Integral2 up) {
   std::uniform_int_distribution<> range(low, up);
-  return range(rng);
+  return range(getRNG());
 }
 
 template <class Mutex>
@@ -186,12 +188,12 @@ template <class Mutex> void testDualLockingWithConst() {
 
       if (i & 1) {
         SYNCHRONIZED_DUAL (v, pv, m, pm) {
-          size_t s = m.size();
+          (void)m.size();
           v.push_back(i);
         }
       } else {
         SYNCHRONIZED_DUAL (m, pm, v, pv) {
-          size_t s = m.size();
+          (void)m.size();
           v.push_back(i);
         }
       }