void setExecutor( std::shared_ptr<Exe> executor, Singleton<std::weak_ptr<Exe>>& sExecutor, Singleton<RWSpinLock, LockTag>& sExecutorLock) { RWSpinLock::WriteHolder guard(sExecutorLock.get()); *sExecutor.get() = std::move(executor); }
std::shared_ptr<Exe> getExecutor( Singleton<std::weak_ptr<Exe>>& sExecutor, Singleton<std::shared_ptr<DefaultExe>>& sDefaultExecutor, Singleton<RWSpinLock, LockTag>& sExecutorLock) { std::shared_ptr<Exe> executor; auto singleton = sExecutor.get(); auto lock = sExecutorLock.get(); { RWSpinLock::ReadHolder guard(lock); if ((executor = sExecutor->lock())) { return executor; } } RWSpinLock::WriteHolder guard(lock); executor = singleton->lock(); if (!executor) { executor = *sDefaultExecutor.get(); *singleton = executor; } return executor; }
FormatRegistry& FormatRegistry::instance() { static Singleton<FormatRegistry> sh; return *sh.get(); }
TestRunner& TestRunner::getDefault() { return *singleton.get(); }
Houses* Houses::getInstance() { static Singleton<Houses> instance; return instance.get(); }
GarbageCollector& GarbageCollector::instance() { return *singleton.get(); }
IOPlayer* IOPlayer::instance() { static Singleton<IOPlayer> instance; return instance.get(); }
ConnectionManager* ConnectionManager::getInstance() { static Singleton<ConnectionManager> instance; return instance.get(); }