diff --git a/FWCore/PluginManager/interface/PluginFactoryBase.h b/FWCore/PluginManager/interface/PluginFactoryBase.h index 2542e7d20a91f..67577ae3beeaa 100644 --- a/FWCore/PluginManager/interface/PluginFactoryBase.h +++ b/FWCore/PluginManager/interface/PluginFactoryBase.h @@ -61,7 +61,7 @@ namespace edmplugin { std::atomic m_ptr; }; - typedef tbb::concurrent_vector PMakers; + typedef tbb::concurrent_vector> PMakers; typedef tbb::concurrent_unordered_map Plugins; // ---------- const member functions --------------------- diff --git a/FWCore/PluginManager/src/PluginFactoryBase.cc b/FWCore/PluginManager/src/PluginFactoryBase.cc index 67c99ec9c9116..7949753961be4 100644 --- a/FWCore/PluginManager/src/PluginFactoryBase.cc +++ b/FWCore/PluginManager/src/PluginFactoryBase.cc @@ -75,6 +75,10 @@ namespace edmplugin { << "'\n but was not there. This means the plugin cache is incorrect. Please run 'EdmPluginRefresh " << lib << "'"; } + //The item in the container can still be under construction so wait until the m_ptr has been set since that is done last + auto const& value = itFound->second.front(); + while (value.m_ptr.load(std::memory_order_acquire) == nullptr) { + } } else { //The item in the container can still be under construction so wait until the m_ptr has been set since that is done last auto const& value = itFound->second.front(); diff --git a/FWCore/PluginManager/src/PluginManager.cc b/FWCore/PluginManager/src/PluginManager.cc index 2d91f8c96326e..5f8da0342fbbd 100644 --- a/FWCore/PluginManager/src/PluginManager.cc +++ b/FWCore/PluginManager/src/PluginManager.cc @@ -251,7 +251,7 @@ namespace edmplugin { throw; } } - loadables_[p] = ptr; + loadables_.emplace(p, ptr); justLoaded_(*ptr); return *ptr; }