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.
This does the same as
D1591270 (which got reverted), but doesn't change destruction order.
Test Plan:
Run tests which were broken by
D1591270
Reviewed By: chip@fb.com
Subscribers: njormrod
FB internal diff:
D1594898
}
SingletonVault* SingletonVault::singleton() {
- static SingletonVault vault;
- return &vault;
+ static SingletonVault* vault = new SingletonVault();
+
+ class SingletonVaultDestructor {
+ public:
+ ~SingletonVaultDestructor() {
+ SingletonVault::singleton()->destroyInstances();
+ }
+ };
+ static SingletonVaultDestructor singletonVaultDestructor;
+
+ return vault;
}
+
}
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;