Don't initialize kDestroyWaitTime in-class
authorChristopher Dykes <cdykes@fb.com>
Wed, 4 May 2016 17:28:12 +0000 (10:28 -0700)
committerFacebook Github Bot 0 <facebook-github-bot-0-bot@fb.com>
Wed, 4 May 2016 17:35:42 +0000 (10:35 -0700)
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
folly/Singleton.cpp
folly/Singleton.h

index 0071ddf5fe752e1fe9edc9366756d97bc4b444d3..a643e0374d413614d78ac627ac303eec5474b198 100644 (file)
@@ -140,6 +140,7 @@ void SingletonHolder<T>::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) {
index 0468679772946a1071de998d5642459e379264b0..ae60d4c9abae28cd50a82d02d012b44e1a3542e7 100644 (file)
@@ -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.
index c5fe79db274c0d15ebcbebf3a7efea282229e2ff..78fa83d2f36a1aaaf38508fc441dc08f73ebe29f 100644 (file)
@@ -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,