Summary: This will ensure SingletonVault is always available. It matters for singletons, not managed by folly::Singleton. Singletons in it will actually be destroyed via static SingletonVaultDestructor.
Test Plan: unit test
Reviewed By: chip@fb.com
Subscribers: njormrod
FB internal diff:
D1591270
}
SingletonVault* SingletonVault::singleton() {
- static SingletonVault vault;
- return &vault;
+ static SingletonVault* vault = new SingletonVault();
+ return vault;
}
+
+namespace {
+
+class SingletonVaultDestructor {
+ public:
+ ~SingletonVaultDestructor() {
+ SingletonVault::singleton()->destroyInstances();
+ }
+};
+
+SingletonVaultDestructor singletonVaultDestructor;
+
+}
+
}
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;