Skip to content
Snippets Groups Projects
Commit 47a56c10 authored by Frank Gaede's avatar Frank Gaede
Browse files

- fixed problem w/ plugin service on MacOs:

    - binary listcomponents had extra instance of PluginService.cpp linked
    -> two instances of the same singleton where created
 - removed debug printout for APPLE
parent 1fe337cf
No related branches found
No related tags found
No related merge requests found
...@@ -19,8 +19,8 @@ if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) ...@@ -19,8 +19,8 @@ if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
SET ( GaudiPluginService_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE ) SET ( GaudiPluginService_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE )
endif() endif()
add_executable(listcomponents src/listcomponents.cpp src/PluginService.cpp) add_executable(listcomponents src/listcomponents.cpp ) #src/PluginService.cpp)
target_link_libraries(listcomponents ${CMAKE_DL_LIBS}) target_link_libraries(listcomponents DD4hepGaudiPluginMgr ${CMAKE_DL_LIBS} )
install(TARGETS listcomponents DD4hepGaudiPluginMgr install(TARGETS listcomponents DD4hepGaudiPluginMgr
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
......
...@@ -24,12 +24,16 @@ ...@@ -24,12 +24,16 @@
#include <cxxabi.h> #include <cxxabi.h>
#include <sys/stat.h> #include <sys/stat.h>
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L #if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
#define REG_SCOPE_LOCK \ #define REG_SCOPE_LOCK \
std::lock_guard<std::recursive_mutex> _guard(m_mutex); std::lock_guard<std::recursive_mutex> _guard(m_mutex);
//namespace Gaudi { namespace PluginService { namespace Details { class Registry ; } } }
namespace { namespace {
std::mutex registrySingletonMutex; std::mutex registrySingletonMutex;
// Gaudi::PluginService::Details::Registry* _theRegistry ;
} }
#define SINGLETON_LOCK \ #define SINGLETON_LOCK \
std::lock_guard<std::mutex> _guard(::registrySingletonMutex); std::lock_guard<std::mutex> _guard(::registrySingletonMutex);
...@@ -133,9 +137,17 @@ namespace Gaudi { namespace PluginService { ...@@ -133,9 +137,17 @@ namespace Gaudi { namespace PluginService {
return demangle(id.name()); return demangle(id.name());
} }
// Registry& Registry::instance() {
// SINGLETON_LOCK
// if( ::_theRegistry == 0 ){
// ::_theRegistry = new Registry ;
// }
// return * ::_theRegistry ;
// }
Registry& Registry::instance() { Registry& Registry::instance() {
SINGLETON_LOCK SINGLETON_LOCK
static Registry r; static Registry r;
return r; return r;
} }
...@@ -253,10 +265,6 @@ namespace Gaudi { namespace PluginService { ...@@ -253,10 +265,6 @@ namespace Gaudi { namespace PluginService {
entry = facts.insert(std::make_pair(id, entry = facts.insert(std::make_pair(id,
FactoryInfo("unknown", factory, FactoryInfo("unknown", factory,
type, rtype, className, props))).first; type, rtype, className, props))).first;
#if APPLE
#define DEBUG_FOR_MAC 1
#endif
#if DEBUG_FOR_MAC #if DEBUG_FOR_MAC
std::cout << " -- registering factory id: " << id << " class : " << className << " with registry " << this << std::endl ; std::cout << " -- registering factory id: " << id << " class : " << className << " with registry " << this << std::endl ;
#endif #endif
......
...@@ -46,15 +46,6 @@ int main(int argc, char* argv[]) { ...@@ -46,15 +46,6 @@ int main(int argc, char* argv[]) {
Gaudi::PluginService::Details::Registry::instance(); Gaudi::PluginService::Details::Registry::instance();
typedef Gaudi::PluginService::Details::Registry::KeyType key_type; typedef Gaudi::PluginService::Details::Registry::KeyType key_type;
#if APPLE
#define DEBUG_FOR_MAC 1
#endif
#if DEBUG_FOR_MAC
Gaudi::PluginService::SetDebug( 2 ) ;
#endif
// cache to keep track of the loaded factories // cache to keep track of the loaded factories
std::map<key_type, std::string> loaded; std::map<key_type, std::string> loaded;
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment