Indestructible
[folly.git] / folly / Random.h
index 8930526edd239aea14ff8ecc4c741231edb4e0c7..53283a286a3d01f07d0a3e783562e7e64bcfdc04 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2016 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 <type_traits>
 #include <random>
 #include <stdint.h>
-#include <folly/ThreadLocal.h>
+#include <folly/Portability.h>
 
-#if __GNUC_PREREQ(4, 8) && !defined(ANDROID)
+#if FOLLY_HAVE_EXTRANDOM_SFMT19937
 #include <ext/random>
-#define FOLLY_USE_SIMD_PRNG 1
 #endif
 
 namespace folly {
@@ -64,18 +63,10 @@ class ThreadLocalPRNG {
   }
   friend class Random;
 
-  ThreadLocalPRNG() {
-    local_ = localInstance.get();
-    if (!local_) {
-      local_ = initLocal();
-    }
-  }
+  ThreadLocalPRNG();
 
  private:
   class LocalInstancePRNG;
-  static LocalInstancePRNG* initLocal();
-  static folly::ThreadLocalPtr<ThreadLocalPRNG::LocalInstancePRNG>
-    localInstance;
 
   static result_type getImpl(LocalInstancePRNG* local);
   LocalInstancePRNG* local_;
@@ -92,7 +83,7 @@ class Random {
 
  public:
   // Default generator type.
-#if FOLLY_USE_SIMD_PRNG
+#if FOLLY_HAVE_EXTRANDOM_SFMT19937
   typedef __gnu_cxx::sfmt19937 DefaultGenerator;
 #else
   typedef std::mt19937 DefaultGenerator;