From 32e0fe56c5f8b6b3e59137eef0b2b24821af0169 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Wed, 4 May 2016 10:28:12 -0700 Subject: [PATCH] Don't initialize kDestroyWaitTime in-class Summary: MSVC doesn't like it when you try to initialize a static in-class non-primitive constexpr member. It was only used in one place, so stick the definition in that function instead. Reviewed By: yfeldblum Differential Revision: D3255178 fb-gh-sync-id: e4a862a2662c4f5376c19fc52827cb2953f01e52 fbshipit-source-id: e4a862a2662c4f5376c19fc52827cb2953f01e52 --- folly/Singleton-inl.h | 1 + folly/Singleton.cpp | 2 -- folly/Singleton.h | 3 --- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/folly/Singleton-inl.h b/folly/Singleton-inl.h index 0071ddf5..a643e037 100644 --- a/folly/Singleton-inl.h +++ b/folly/Singleton-inl.h @@ -140,6 +140,7 @@ void SingletonHolder::destroyInstance() { 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) { diff --git a/folly/Singleton.cpp b/folly/Singleton.cpp index 04686797..ae60d4c9 100644 --- a/folly/Singleton.cpp +++ b/folly/Singleton.cpp @@ -29,8 +29,6 @@ namespace folly { namespace detail { -constexpr std::chrono::seconds SingletonHolderBase::kDestroyWaitTime; - [[noreturn]] void singletonWarnDoubleRegistrationAndAbort( const TypeDescriptor& type) { // Not using LOG(FATAL) or std::cerr because they may not be initialized yet. diff --git a/folly/Singleton.h b/folly/Singleton.h index c5fe79db..78fa83d2 100644 --- a/folly/Singleton.h +++ b/folly/Singleton.h @@ -225,9 +225,6 @@ class SingletonHolderBase { virtual void createInstance() = 0; virtual bool creationStarted() = 0; virtual void destroyInstance() = 0; - - protected: - static constexpr std::chrono::seconds kDestroyWaitTime{5}; }; // An actual instance of a singleton, tracking the instance itself, -- 2.34.1