Revert "Leak folly::SingletonVault"
authorDaniel Sommermann <dcsommer@fb.com>
Thu, 2 Oct 2014 22:19:27 +0000 (15:19 -0700)
committerAndrii Grynenko <andrii@fb.com>
Wed, 15 Oct 2014 00:50:44 +0000 (17:50 -0700)
Summary:
This reverts commit 3cf88fb680b4b9c47189d1e12699e2c24c7ac38b. It
was timing out our tests. probably static (de)initialization order fiasco related.

Test Plan: watch contbuild, git bisect

Reviewed By: afrind@fb.com

Subscribers: doug, njormrod

FB internal diff: D1593016

folly/experimental/Singleton.cpp
folly/experimental/Singleton.h

index ee4b202164ade72fa40705ac202576c7e0153543..7934ab1a8a7a0b1804e49a81c1f7e53b65fa0c6d 100644 (file)
@@ -55,21 +55,7 @@ void SingletonVault::destroyInstances() {
 }
 
 SingletonVault* SingletonVault::singleton() {
-  static SingletonVault* vault = new SingletonVault();
-  return vault;
+  static SingletonVault vault;
+  return &vault;
 }
-
-namespace {
-
-class SingletonVaultDestructor {
- public:
-  ~SingletonVaultDestructor() {
-    SingletonVault::singleton()->destroyInstances();
-  }
-};
-
-SingletonVaultDestructor singletonVaultDestructor;
-
-}
-
 }
index cbbd03199503b4b281461b86130550836f27ae36..c2100e0d90773a7009b75d8fbc5eb67d0c1831f6 100644 (file)
@@ -167,8 +167,6 @@ class SingletonVault {
   enum class Type { Strict, Relaxed };
 
   explicit SingletonVault(Type type = Type::Relaxed) : type_(type) {}
-
-  // Destructor is only called by unit tests to check destroyInstances.
   ~SingletonVault();
 
   typedef std::function<void(void*)> TeardownFunc;