rm5248 commented on a change in pull request #93:
URL: https://github.com/apache/logging-log4cxx/pull/93#discussion_r777154084



##########
File path: src/main/cpp/logmanager.cpp
##########
@@ -47,28 +47,19 @@ using namespace log4cxx::helpers;
 IMPLEMENT_LOG4CXX_OBJECT(DefaultRepositorySelector)
 
 void* LogManager::guard = 0;
-spi::RepositorySelectorPtr LogManager::repositorySelector;
-
 
 RepositorySelectorPtr LogManager::getRepositorySelector()
 {
-       //
-       //     call to initialize APR and trigger "start" of logging clock
-       //
-       APRInitializer::initialize();
-
-       if (!repositorySelector)
-       {
-               LoggerRepositoryPtr hierarchy = Hierarchy::create();
-               RepositorySelectorPtr selector(new 
DefaultRepositorySelector(hierarchy));
-               repositorySelector = selector;
-       }
-
-       return repositorySelector;
+       auto result = APRInitializer::getUnique<spi::RepositorySelector>( []() 
-> ObjectPtr
+               {
+                       LoggerRepositoryPtr hierarchy = Hierarchy::create();
+                       return ObjectPtr(new 
DefaultRepositorySelector(hierarchy));
+               }
+       );

Review comment:
       `getOrAddUnique<T>` sounds fine to me.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to