From: Anthony Geay Date: Fri, 5 Jan 2024 14:45:04 +0000 (+0100) Subject: [EDF29150] : LogManager instance pointed by salome.logm is a singleton. X-Git-Tag: emc2p_1.6.0-rc1~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bd3a8f6337d7e09fafb2158ef6edb8a521cd2d75;p=modules%2Fkernel.git [EDF29150] : LogManager instance pointed by salome.logm is a singleton. --- diff --git a/src/Launcher/KernelLauncher.cxx b/src/Launcher/KernelLauncher.cxx index 31297ad64..f7939f4bb 100644 --- a/src/Launcher/KernelLauncher.cxx +++ b/src/Launcher/KernelLauncher.cxx @@ -31,6 +31,8 @@ #include #include +static Engines::LogManager_var LogManagerInstanceSingleton; + std::string RetrieveInternalInstanceOfLocalCppResourcesManager() { SALOME_Launcher *launcher = KERNEL::getLauncherSA(); @@ -87,25 +89,28 @@ std::string GetExternalServerInstance() std::string GetLogManagerInstance() { CORBA::ORB_ptr orb = KERNEL::getORB(); - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); - PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); - // - CORBA::PolicyList policies; - policies.length(1); - PortableServer::POAManager_var pman = root_poa->the_POAManager(); - PortableServer::ThreadPolicy_var threadPol(root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL)); - policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol); - PortableServer::POA_var safePOA = root_poa->create_POA("SingleThreadPOAForLogManager",pman,policies); - threadPol->destroy(); - // - SALOME_CPythonHelper *cPyh(SALOME_CPythonHelper::Singleton()); - SALOME_Fake_NamingService *ns = new SALOME_Fake_NamingService; - SALOME_LogManager *esm(new SALOME_LogManager(orb,safePOA,ns)); - esm->_remove_ref(); - // - CORBA::Object_var esmPtr = safePOA->servant_to_reference(esm); - Engines::LogManager_var esmCPtr = Engines::LogManager::_narrow(esmPtr); + if( CORBA::is_nil(LogManagerInstanceSingleton) ) + { + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); + // + CORBA::PolicyList policies; + policies.length(1); + PortableServer::POAManager_var pman = root_poa->the_POAManager(); + PortableServer::ThreadPolicy_var threadPol(root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL)); + policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol); + PortableServer::POA_var safePOA = root_poa->create_POA("SingleThreadPOAForLogManager",pman,policies); + threadPol->destroy(); + // + SALOME_CPythonHelper *cPyh(SALOME_CPythonHelper::Singleton()); + SALOME_Fake_NamingService *ns = new SALOME_Fake_NamingService; + SALOME_LogManager *esm(new SALOME_LogManager(orb,safePOA,ns)); + esm->_remove_ref(); + // + CORBA::Object_var esmPtr = safePOA->servant_to_reference(esm); + LogManagerInstanceSingleton = Engines::LogManager::_narrow(esmPtr); + } // - CORBA::String_var ior = orb->object_to_string(esmCPtr); + CORBA::String_var ior = orb->object_to_string(LogManagerInstanceSingleton); return std::string(ior.in()); }