return *entry;
}
+[[noreturn]] void singletonWarnDoubleRegistrationAndAbort(
+ const TypeDescriptor& type);
+
template <typename T>
void SingletonHolder<T>::registerSingleton(CreateFunc c, TeardownFunc t) {
std::lock_guard<std::mutex> entry_lock(mutex_);
* Singleton<int> b([] { return new int(4); });
*
*/
- LOG(FATAL) << "Double registration of singletons of the same "
- << "underlying type; check for multiple definitions "
- << "of type folly::Singleton<" + type_.name() + ">";
+ singletonWarnDoubleRegistrationAndAbort(type_);
}
create_ = std::move(c);
state_ = SingletonHolderState::Dead;
instance_.reset();
if (destroy_baton_) {
+ constexpr std::chrono::seconds kDestroyWaitTime{5};
auto wait_result = destroy_baton_->timed_wait(
std::chrono::steady_clock::now() + kDestroyWaitTime);
if (!wait_result) {