diff --git a/ApacheConnector/src/ApacheApplication.cpp b/ApacheConnector/src/ApacheApplication.cpp index 114356e6c..eb6816ce2 100644 --- a/ApacheConnector/src/ApacheApplication.cpp +++ b/ApacheConnector/src/ApacheApplication.cpp @@ -11,7 +11,6 @@ #include "ApacheApplication.h" #include "ApacheChannel.h" #include "Poco/Logger.h" -#include "Poco/SingletonHolder.h" #include @@ -48,6 +47,6 @@ void ApacheApplication::setup() ApacheApplication& ApacheApplication::instance() { - static Poco::SingletonHolder sh; - return *sh.get(); + static ApacheApplication aa; + return aa; } diff --git a/Crypto/src/CipherFactory.cpp b/Crypto/src/CipherFactory.cpp index 9e59dc267..e01c73472 100644 --- a/Crypto/src/CipherFactory.cpp +++ b/Crypto/src/CipherFactory.cpp @@ -20,7 +20,6 @@ #include "Poco/Crypto/RSACipherImpl.h" #include "Poco/Crypto/EVPCipherImpl.h" #include "Poco/Exception.h" -#include "Poco/SingletonHolder.h" #include #include #if OPENSSL_VERSION_NUMBER >= 0x30000000L @@ -46,15 +45,10 @@ CipherFactory::~CipherFactory() } -namespace -{ - static Poco::SingletonHolder holder; -} - - CipherFactory& CipherFactory::defaultFactory() { - return *holder.get(); + static CipherFactory cf; + return cf; } diff --git a/Data/MySQL/src/SessionHandle.cpp b/Data/MySQL/src/SessionHandle.cpp index ce28a7cfb..6a167a131 100644 --- a/Data/MySQL/src/SessionHandle.cpp +++ b/Data/MySQL/src/SessionHandle.cpp @@ -14,7 +14,6 @@ #include "Poco/Data/MySQL/SessionHandle.h" #include "Poco/Data/DataException.h" -#include "Poco/SingletonHolder.h" #ifdef POCO_OS_FAMILY_UNIX #include #endif @@ -51,7 +50,8 @@ public: static ThreadCleanupHelper& instance() { - return *_sh.get(); + static ThreadCleanupHelper tch; + return tch; } static void cleanup(void* data) @@ -61,11 +61,9 @@ public: private: pthread_key_t _key; - static Poco::SingletonHolder _sh; }; -Poco::SingletonHolder ThreadCleanupHelper::_sh; #endif diff --git a/Foundation/src/ActiveThreadPool.cpp b/Foundation/src/ActiveThreadPool.cpp index ed52f6330..628c78d6d 100644 --- a/Foundation/src/ActiveThreadPool.cpp +++ b/Foundation/src/ActiveThreadPool.cpp @@ -352,14 +352,9 @@ private: }; -namespace -{ - static ActiveThreadPoolSingletonHolder sh; -} - - ActiveThreadPool& ActiveThreadPool::defaultPool() { + static ActiveThreadPoolSingletonHolder sh; return *sh.pool(); } diff --git a/Foundation/src/ErrorHandler.cpp b/Foundation/src/ErrorHandler.cpp index 6e60161f3..d8bfe7dc1 100644 --- a/Foundation/src/ErrorHandler.cpp +++ b/Foundation/src/ErrorHandler.cpp @@ -13,7 +13,6 @@ #include "Poco/ErrorHandler.h" -#include "Poco/SingletonHolder.h" namespace Poco { @@ -103,11 +102,8 @@ ErrorHandler* ErrorHandler::set(ErrorHandler* pHandler) ErrorHandler* ErrorHandler::defaultHandler() { - // NOTE: Since this is called to initialize the static _pHandler - // variable, sh has to be a local static, otherwise we run - // into static initialization order issues. - static SingletonHolder sh; - return sh.get(); + static ErrorHandler eh; + return &eh; } diff --git a/Foundation/src/LoggingFactory.cpp b/Foundation/src/LoggingFactory.cpp index 5d31b8f02..049c49e50 100644 --- a/Foundation/src/LoggingFactory.cpp +++ b/Foundation/src/LoggingFactory.cpp @@ -13,7 +13,6 @@ #include "Poco/LoggingFactory.h" -#include "Poco/SingletonHolder.h" #include "Poco/AsyncChannel.h" #include "Poco/ConsoleChannel.h" #include "Poco/FileChannel.h" @@ -73,15 +72,10 @@ Formatter::Ptr LoggingFactory::createFormatter(const std::string& className) con } -namespace -{ - static SingletonHolder sh; -} - - LoggingFactory& LoggingFactory::defaultFactory() { - return *sh.get(); + static LoggingFactory lf; + return lf; } diff --git a/Foundation/src/LoggingRegistry.cpp b/Foundation/src/LoggingRegistry.cpp index 7bf6e53d0..652d93d49 100644 --- a/Foundation/src/LoggingRegistry.cpp +++ b/Foundation/src/LoggingRegistry.cpp @@ -13,7 +13,6 @@ #include "Poco/LoggingRegistry.h" -#include "Poco/SingletonHolder.h" namespace Poco { @@ -102,15 +101,10 @@ void LoggingRegistry::clear() } -namespace -{ - static SingletonHolder sh; -} - - LoggingRegistry& LoggingRegistry::defaultRegistry() { - return *sh.get(); + static LoggingRegistry lr; + return lr; } diff --git a/Foundation/src/NestedDiagnosticContext.cpp b/Foundation/src/NestedDiagnosticContext.cpp index 3be966ace..64004b55c 100644 --- a/Foundation/src/NestedDiagnosticContext.cpp +++ b/Foundation/src/NestedDiagnosticContext.cpp @@ -13,7 +13,6 @@ #include "Poco/NestedDiagnosticContext.h" -#include "Poco/SingletonHolder.h" #include "Poco/ThreadLocal.h" @@ -114,15 +113,10 @@ void NestedDiagnosticContext::clear() } -namespace -{ - static ThreadLocal ndc; -} - - NestedDiagnosticContext& NestedDiagnosticContext::current() { - return ndc.get(); + static NestedDiagnosticContext ndc; + return ndc; } diff --git a/Foundation/src/NotificationCenter.cpp b/Foundation/src/NotificationCenter.cpp index eb7e76cb2..ea235ef56 100644 --- a/Foundation/src/NotificationCenter.cpp +++ b/Foundation/src/NotificationCenter.cpp @@ -16,7 +16,6 @@ #include "Poco/Notification.h" #include "Poco/Observer.h" #include "Poco/AutoPtr.h" -#include "Poco/SingletonHolder.h" namespace Poco { @@ -106,15 +105,10 @@ std::size_t NotificationCenter::countObservers() const } -namespace -{ - static SingletonHolder sh; -} - - NotificationCenter& NotificationCenter::defaultCenter() { - return *sh.get(); + static NotificationCenter nc; + return nc; } diff --git a/Foundation/src/NotificationQueue.cpp b/Foundation/src/NotificationQueue.cpp index c365baeab..2eabc63a9 100644 --- a/Foundation/src/NotificationQueue.cpp +++ b/Foundation/src/NotificationQueue.cpp @@ -15,7 +15,6 @@ #include "Poco/NotificationQueue.h" #include "Poco/NotificationCenter.h" #include "Poco/Notification.h" -#include "Poco/SingletonHolder.h" namespace Poco { @@ -209,15 +208,10 @@ Notification::Ptr NotificationQueue::dequeueOne() } -namespace -{ - static SingletonHolder sh; -} - - NotificationQueue& NotificationQueue::defaultQueue() { - return *sh.get(); + static NotificationQueue nq; + return nq; } diff --git a/Foundation/src/PriorityNotificationQueue.cpp b/Foundation/src/PriorityNotificationQueue.cpp index 541611d47..b9baa7de7 100644 --- a/Foundation/src/PriorityNotificationQueue.cpp +++ b/Foundation/src/PriorityNotificationQueue.cpp @@ -15,7 +15,6 @@ #include "Poco/PriorityNotificationQueue.h" #include "Poco/NotificationCenter.h" #include "Poco/Notification.h" -#include "Poco/SingletonHolder.h" namespace Poco { @@ -180,15 +179,10 @@ Notification::Ptr PriorityNotificationQueue::dequeueOne() } -namespace -{ - static SingletonHolder sh; -} - - PriorityNotificationQueue& PriorityNotificationQueue::defaultQueue() { - return *sh.get(); + static PriorityNotificationQueue pnq; + return pnq; } diff --git a/Foundation/src/TextEncoding.cpp b/Foundation/src/TextEncoding.cpp index 1e1f3d075..f13fe06e5 100644 --- a/Foundation/src/TextEncoding.cpp +++ b/Foundation/src/TextEncoding.cpp @@ -26,7 +26,6 @@ #include "Poco/Windows1251Encoding.h" #include "Poco/Windows1252Encoding.h" #include "Poco/RWLock.h" -#include "Poco/SingletonHolder.h" #include @@ -193,15 +192,10 @@ TextEncoding& TextEncoding::global() } -namespace -{ - static SingletonHolder sh; -} - - TextEncodingManager& TextEncoding::manager() { - return *sh.get(); + static TextEncodingManager tem; + return tem; } diff --git a/Foundation/src/ThreadLocal.cpp b/Foundation/src/ThreadLocal.cpp index aa1fb2ff8..16bf9d69e 100644 --- a/Foundation/src/ThreadLocal.cpp +++ b/Foundation/src/ThreadLocal.cpp @@ -13,7 +13,6 @@ #include "Poco/ThreadLocal.h" -#include "Poco/SingletonHolder.h" #include "Poco/Thread.h" @@ -54,12 +53,6 @@ TLSAbstractSlot*& ThreadLocalStorage::get(const void* key) } -namespace -{ - static SingletonHolder sh; -} - - ThreadLocalStorage& ThreadLocalStorage::current() { Thread* pThread = Thread::current(); @@ -69,7 +62,8 @@ ThreadLocalStorage& ThreadLocalStorage::current() } else { - return *sh.get(); + static ThreadLocalStorage tls; + return tls; } } diff --git a/Foundation/src/ThreadPool.cpp b/Foundation/src/ThreadPool.cpp index bb3f59600..0aeb11d2b 100644 --- a/Foundation/src/ThreadPool.cpp +++ b/Foundation/src/ThreadPool.cpp @@ -497,14 +497,9 @@ private: }; -namespace -{ - static ThreadPoolSingletonHolder sh; -} - - ThreadPool& ThreadPool::defaultPool() { + static ThreadPoolSingletonHolder sh; return *sh.pool(); } diff --git a/Foundation/src/URIStreamOpener.cpp b/Foundation/src/URIStreamOpener.cpp index fa59a0763..79243ffde 100644 --- a/Foundation/src/URIStreamOpener.cpp +++ b/Foundation/src/URIStreamOpener.cpp @@ -17,7 +17,6 @@ #include "Poco/FileStreamFactory.h" #include "Poco/URI.h" #include "Poco/Path.h" -#include "Poco/SingletonHolder.h" #include "Poco/Exception.h" @@ -159,15 +158,10 @@ bool URIStreamOpener::supportsScheme(const std::string& scheme) } -namespace -{ - static SingletonHolder sh; -} - - URIStreamOpener& URIStreamOpener::defaultOpener() { - return *sh.get(); + static URIStreamOpener so; + return so; } diff --git a/Foundation/src/UUIDGenerator.cpp b/Foundation/src/UUIDGenerator.cpp index e51add84f..078e669fd 100644 --- a/Foundation/src/UUIDGenerator.cpp +++ b/Foundation/src/UUIDGenerator.cpp @@ -18,7 +18,6 @@ #include "Poco/DigestEngine.h" #include "Poco/MD5Engine.h" #include "Poco/SHA1Engine.h" -#include "Poco/SingletonHolder.h" #include @@ -152,15 +151,10 @@ void UUIDGenerator::seed(UInt32 n) } -namespace -{ - static SingletonHolder sh; -} - - UUIDGenerator& UUIDGenerator::defaultGenerator() { - return *sh.get(); + static UUIDGenerator g; + return g; } diff --git a/Net/src/HTTPSessionFactory.cpp b/Net/src/HTTPSessionFactory.cpp index 01b86666b..66024b186 100644 --- a/Net/src/HTTPSessionFactory.cpp +++ b/Net/src/HTTPSessionFactory.cpp @@ -17,7 +17,6 @@ #include "Poco/Exception.h" -using Poco::SingletonHolder; using Poco::FastMutex; using Poco::NotFoundException; using Poco::ExistsException; @@ -137,15 +136,10 @@ void HTTPSessionFactory::setProxyConfig(const HTTPClientSession::ProxyConfig& pr } -namespace -{ - static SingletonHolder singleton; -} - - HTTPSessionFactory& HTTPSessionFactory::defaultFactory() { - return *singleton.get(); + static HTTPSessionFactory f; + return f; } diff --git a/Net/src/SSPINTLMCredentials.cpp b/Net/src/SSPINTLMCredentials.cpp index 9a59b1c36..849b62fe5 100644 --- a/Net/src/SSPINTLMCredentials.cpp +++ b/Net/src/SSPINTLMCredentials.cpp @@ -19,7 +19,6 @@ #include "Poco/SharedLibrary.h" -#include "Poco/SingletonHolder.h" #include "Poco/UnicodeConverter.h" #include #define WIN32_LEAN_AND_MEAN @@ -227,15 +226,10 @@ private: }; -namespace -{ - static Poco::SingletonHolder sspintlmProviderHolder; -} - - SSPINTLMProvider& SSPINTLMProvider::instance() { - return *sspintlmProviderHolder.get(); + static SSPINTLMProvider p; + return p; } diff --git a/NetSSL_OpenSSL/src/SSLManager.cpp b/NetSSL_OpenSSL/src/SSLManager.cpp index 4ea45ab6e..0d53b1844 100644 --- a/NetSSL_OpenSSL/src/SSLManager.cpp +++ b/NetSSL_OpenSSL/src/SSLManager.cpp @@ -24,7 +24,6 @@ #include "Poco/Net/RejectCertificateHandler.h" #include "Poco/Crypto/OpenSSLInitializer.h" #include "Poco/Net/SSLException.h" -#include "Poco/SingletonHolder.h" #include "Poco/Delegate.h" #include "Poco/StringTokenizer.h" #include "Poco/Util/Application.h" @@ -107,15 +106,10 @@ void SSLManager::shutdown() } -namespace -{ - static Poco::SingletonHolder singleton; -} - - SSLManager& SSLManager::instance() { - return *singleton.get(); + static SSLManager sm; + return sm; } diff --git a/NetSSL_Win/src/SSLManager.cpp b/NetSSL_Win/src/SSLManager.cpp index 40be6ebaa..4f113b180 100644 --- a/NetSSL_Win/src/SSLManager.cpp +++ b/NetSSL_Win/src/SSLManager.cpp @@ -22,7 +22,6 @@ #include "Poco/Net/Utility.h" #include "Poco/Net/PrivateKeyPassphraseHandler.h" #include "Poco/Net/RejectCertificateHandler.h" -#include "Poco/SingletonHolder.h" #include "Poco/Delegate.h" #include "Poco/Util/Application.h" #include "Poco/Util/OptionException.h" @@ -81,15 +80,10 @@ SSLManager::~SSLManager() } -namespace -{ - static Poco::SingletonHolder singleton; -} - - SSLManager& SSLManager::instance() { - return *singleton.get(); + static SSLManager sm; + return sm; } diff --git a/NetSSL_Win/src/SecureSocketImpl.cpp b/NetSSL_Win/src/SecureSocketImpl.cpp index c7b9c7e6e..044a7a8c3 100644 --- a/NetSSL_Win/src/SecureSocketImpl.cpp +++ b/NetSSL_Win/src/SecureSocketImpl.cpp @@ -1569,15 +1569,10 @@ void SecureSocketImpl::stateMachine() } -namespace -{ - static Poco::SingletonHolder stateMachineSingleton; -} - - StateMachine& StateMachine::instance() { - return *stateMachineSingleton.get(); + static StateMachine sm; + return sm; } diff --git a/Prometheus/src/Registry.cpp b/Prometheus/src/Registry.cpp index eff7b4c7c..ae2fd0b3e 100644 --- a/Prometheus/src/Registry.cpp +++ b/Prometheus/src/Registry.cpp @@ -15,7 +15,6 @@ #include "Poco/Prometheus/Registry.h" #include "Poco/Prometheus/Collector.h" #include "Poco/Exception.h" -#include "Poco/SingletonHolder.h" using namespace std::string_literals; @@ -90,15 +89,10 @@ void Registry::exportTo(Exporter& exporter) const } -namespace -{ - static SingletonHolder sh; -} - - Registry& Registry::defaultRegistry() { - return *sh.get(); + static Registry r; + return r; } diff --git a/XML/src/DOMImplementation.cpp b/XML/src/DOMImplementation.cpp index 208d6499e..c2d0d76a8 100644 --- a/XML/src/DOMImplementation.cpp +++ b/XML/src/DOMImplementation.cpp @@ -17,7 +17,6 @@ #include "Poco/DOM/Document.h" #include "Poco/DOM/Element.h" #include "Poco/String.h" -#include "Poco/SingletonHolder.h" namespace Poco { @@ -71,15 +70,10 @@ Document* DOMImplementation::createDocument(const XMLString& namespaceURI, const } -namespace -{ - static Poco::SingletonHolder sh; -} - - const DOMImplementation& DOMImplementation::instance() { - return *sh.get(); + static DOMImplementation di; + return di; }