/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
};
- explicit SingletonVault(Type type = Type::Relaxed) : type_(type) {}
+ explicit SingletonVault(Type type = Type::Strict) : type_(type) {}
// Destructor is only called by unit tests to check destroyInstances.
~SingletonVault();
eagerInitSingletons_;
folly::Synchronized<std::vector<detail::TypeDescriptor>> creationOrder_;
- folly::Synchronized<State> state_;
+ // Using SharedMutexReadPriority is important here, because we want to make
+ // sure we don't block nested singleton creation happening concurrently with
+ // destroyInstances().
+ folly::Synchronized<State, folly::SharedMutexReadPriority> state_;
- Type type_{Type::Relaxed};
+ Type type_;
};
// This is the wrapper class that most users actually interact with.