From 11ff9f99f2439830f4e7b8e623583508b1bbbebf Mon Sep 17 00:00:00 2001 From: Daniel Sommermann Date: Thu, 2 Oct 2014 15:19:27 -0700 Subject: [PATCH] Revert "Leak folly::SingletonVault" 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 | 18 ++---------------- folly/experimental/Singleton.h | 2 -- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/folly/experimental/Singleton.cpp b/folly/experimental/Singleton.cpp index ee4b2021..7934ab1a 100644 --- a/folly/experimental/Singleton.cpp +++ b/folly/experimental/Singleton.cpp @@ -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; - -} - } diff --git a/folly/experimental/Singleton.h b/folly/experimental/Singleton.h index cbbd0319..c2100e0d 100644 --- a/folly/experimental/Singleton.h +++ b/folly/experimental/Singleton.h @@ -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 TeardownFunc; -- 2.34.1