#include <folly/Singleton.h>
#ifndef _WIN32
#include <dlfcn.h>
#include <signal.h>
#include <time.h>
#endif
#include <atomic>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <fmt/chrono.h>
#include <fmt/format.h>
#include <folly/Demangle.h>
#include <folly/ScopeGuard.h>
#include <folly/experimental/symbolizer/Symbolizer.h>
#include <folly/lang/SafeAssert.h>
#include <folly/portability/Config.h>
#include <folly/portability/FmtCompile.h>
#include <glog/raw_logging.h>
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__)
#define FOLLY_SINGLETON_HAVE_DLSYM …
#endif
namespace folly {
#if FOLLY_SINGLETON_HAVE_DLSYM
namespace detail {
static void singleton_hs_init_weak(int* argc, char** argv[])
__attribute__((__weakref__("hs_init")));
}
#endif
SingletonVault::Type SingletonVault::defaultVaultType() { … }
namespace detail {
std::string TypeDescriptor::name() const { … }
[[noreturn]] void singletonWarnDoubleRegistrationAndAbort(
const TypeDescriptor& type) { … }
[[noreturn]] void singletonWarnLeakyDoubleRegistrationAndAbort(
const TypeDescriptor& type) { … }
[[noreturn]] void singletonWarnLeakyInstantiatingNotRegisteredAndAbort(
const TypeDescriptor& type) { … }
[[noreturn]] void singletonWarnRegisterMockEarlyAndAbort(
const TypeDescriptor& type) { … }
void singletonWarnDestroyInstanceLeak(
const TypeDescriptor& type, const void* ptr) { … }
[[noreturn]] void singletonWarnCreateCircularDependencyAndAbort(
const TypeDescriptor& type) { … }
[[noreturn]] void singletonWarnCreateUnregisteredAndAbort(
const TypeDescriptor& type) { … }
[[noreturn]] void singletonWarnCreateBeforeRegistrationCompleteAndAbort(
const TypeDescriptor& type) { … }
void singletonPrintDestructionStackTrace(const TypeDescriptor& type) { … }
[[noreturn]] void singletonThrowNullCreator(const std::type_info& type) { … }
[[noreturn]] void singletonThrowGetInvokedAfterDestruction(
const TypeDescriptor& type) { … }
}
namespace {
struct FatalHelper { … };
#if defined(__APPLE__) || defined(_MSC_VER)
FatalHelper fatalHelper;
#else
FatalHelper __attribute__((__init_priority__(101))) fatalHelper;
#endif
}
SingletonVault::SingletonVault(Type type) noexcept : … { … }
SingletonVault::~SingletonVault() { … }
void SingletonVault::registerSingleton(detail::SingletonHolderBase* entry) { … }
void SingletonVault::addEagerInitSingleton(detail::SingletonHolderBase* entry) { … }
void SingletonVault::addEagerInitOnReenableSingleton(
detail::SingletonHolderBase* entry) { … }
void SingletonVault::registrationComplete() { … }
void SingletonVault::doEagerInit() { … }
void SingletonVault::doEagerInitVia(Executor& exe, folly::Baton<>* done) { … }
void SingletonVault::destroyInstances() { … }
void SingletonVault::reenableInstances() { … }
void SingletonVault::scheduleDestroyInstances() { … }
void SingletonVault::destroyInstancesFinal() { … }
void SingletonVault::addToShutdownLog(std::string message) { … }
#if FOLLY_HAVE_LIBRT
namespace {
[[noreturn]] void fireShutdownSignalHelper(sigval_t sigval) {
static_cast<SingletonVault*>(sigval.sival_ptr)->fireShutdownTimer();
}
}
#endif
void SingletonVault::startShutdownTimer() { … }
[[noreturn]] void SingletonVault::fireShutdownTimer() { … }
}