Commit c7656e1f authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot 6

Don't allow getting singleton after shutdown in strict mode

Summary: Make strict mode stricter, by not allowing singleton to be fetched after shutdown (even with try_get).

Reviewed By: yfeldblum

Differential Revision: D3737925

fbshipit-source-id: 8d5536c4f27e13feee722b5abeb15db6fe3d77bf
parent 79212dac
...@@ -226,6 +226,9 @@ void SingletonHolder<T>::createInstance() { ...@@ -226,6 +226,9 @@ void SingletonHolder<T>::createInstance() {
RWSpinLock::ReadHolder rh(&vault_.stateMutex_); RWSpinLock::ReadHolder rh(&vault_.stateMutex_);
if (vault_.state_ == SingletonVault::SingletonVaultState::Quiescing) { if (vault_.state_ == SingletonVault::SingletonVaultState::Quiescing) {
if (vault_.type_ != SingletonVault::Type::Relaxed) {
LOG(FATAL) << "Requesting singleton after vault was destroyed.";
}
return; return;
} }
......
...@@ -448,6 +448,10 @@ class SingletonVault { ...@@ -448,6 +448,10 @@ class SingletonVault {
return *stackTraceGetterPtr; return *stackTraceGetterPtr;
} }
void setType(Type type) {
type_ = type;
}
private: private:
template <typename T> template <typename T>
friend struct detail::SingletonHolder; friend struct detail::SingletonHolder;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment