CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
edmtest::TestServicesOnNonFrameworkThreadsAnalyzer Class Reference
Inheritance diagram for edmtest::TestServicesOnNonFrameworkThreadsAnalyzer:
edm::stream::EDAnalyzer<> edm::stream::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (edm::Event const &, edm::EventSetup const &) final
 
 TestServicesOnNonFrameworkThreadsAnalyzer (edm::ParameterSet const &)
 
 ~TestServicesOnNonFrameworkThreadsAnalyzer () override
 
- Public Member Functions inherited from edm::stream::EDAnalyzer<>
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
 EDAnalyzerBase (const EDAnalyzerBase &)=delete
 
ModuleDescription const & moduleDescription () const
 
const EDAnalyzerBaseoperator= (const EDAnalyzerBase &)=delete
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void runOnOtherThread ()
 
void shutdownThread ()
 

Private Attributes

std::condition_variable m_condVar
 
bool m_continueProcessing = false
 
bool m_eventWorkDone = false
 
std::exception_ptr m_except
 
bool m_managerThreadReady = false
 
edm::ModuleCallingContext const * m_moduleCallingContext = nullptr
 
std::mutex m_mutex
 
edm::ServiceTokenm_serviceToken = nullptr
 
edm::StreamID m_streamID
 
std::unique_ptr< std::thread > m_thread
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 21 of file TestServicesOnNonFrameworkThreadsAnalyzer.cc.

Constructor & Destructor Documentation

◆ TestServicesOnNonFrameworkThreadsAnalyzer()

edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::TestServicesOnNonFrameworkThreadsAnalyzer ( edm::ParameterSet const &  )

◆ ~TestServicesOnNonFrameworkThreadsAnalyzer()

edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::~TestServicesOnNonFrameworkThreadsAnalyzer ( )
override

Member Function Documentation

◆ analyze()

void edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &   
)
finalvirtual

Implements edm::stream::EDAnalyzerBase.

Definition at line 61 of file TestServicesOnNonFrameworkThreadsAnalyzer.cc.

References iEvent, edm::ServiceRegistry::instance(), m_condVar, m_eventWorkDone, m_except, m_managerThreadReady, m_moduleCallingContext, m_mutex, m_serviceToken, m_streamID, edm::ServiceRegistry::presentToken(), and unpackBuffers-CaloStage2::token.

61  {
62  m_eventWorkDone = false;
63  m_moduleCallingContext = iEvent.moduleCallingContext();
66  m_streamID = iEvent.streamID();
67  { edm::LogSystem("FrameworkThread") << "new Event"; }
68  m_mutex.unlock();
69  {
70  std::unique_lock<std::mutex> lk(m_mutex);
71  m_condVar.notify_one();
72  m_condVar.wait(lk, [this] { return this->m_eventWorkDone; });
73  lk.release();
74  }
75  edm::LogSystem("FrameworkThread") << " done";
76  m_managerThreadReady = true;
77  if (m_except) {
78  std::rethrow_exception(m_except);
79  }
80  }
Log< level::System, false > LogSystem
int iEvent
Definition: GenABIO.cc:224
static ServiceRegistry & instance()
ServiceToken presentToken() const

◆ runOnOtherThread()

void edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::runOnOtherThread ( )
private

Definition at line 82 of file TestServicesOnNonFrameworkThreadsAnalyzer.cc.

References edm::RandomNumberGenerator::getEngine(), m_condVar, m_continueProcessing, m_eventWorkDone, m_except, m_managerThreadReady, m_moduleCallingContext, m_mutex, m_serviceToken, m_streamID, edm_modernize_messagelogger::ml, and edm::ModuleCallingContext::parent().

Referenced by TestServicesOnNonFrameworkThreadsAnalyzer().

82  {
83  std::unique_lock<std::mutex> lk(m_mutex);
84 
85  do {
86  m_condVar.wait(lk, [this] { return m_managerThreadReady; });
90 
92  try {
95  ml->setThreadContext(*m_moduleCallingContext);
96  edm::LogSystem("ModuleThread") << " ++running with rng "
97  << CLHEP::RandFlat::shootInt(&rng->getEngine(m_streamID), 10);
98  } catch (...) {
99  m_except = std::current_exception();
100  }
101  }
102  m_eventWorkDone = true;
103  m_managerThreadReady = false;
104  lk.unlock();
105  m_condVar.notify_one();
106  lk.lock();
107  } while (m_continueProcessing);
108  }
Log< level::System, false > LogSystem
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
ParentContext const & parent() const

◆ shutdownThread()

void edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::shutdownThread ( )
private

Member Data Documentation

◆ m_condVar

std::condition_variable edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_condVar
private

◆ m_continueProcessing

bool edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_continueProcessing = false
private

◆ m_eventWorkDone

bool edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_eventWorkDone = false
private

Definition at line 37 of file TestServicesOnNonFrameworkThreadsAnalyzer.cc.

Referenced by analyze(), and runOnOtherThread().

◆ m_except

std::exception_ptr edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_except
private

Definition at line 43 of file TestServicesOnNonFrameworkThreadsAnalyzer.cc.

Referenced by analyze(), and runOnOtherThread().

◆ m_managerThreadReady

bool edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_managerThreadReady = false
private

◆ m_moduleCallingContext

edm::ModuleCallingContext const* edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_moduleCallingContext = nullptr
private

Definition at line 40 of file TestServicesOnNonFrameworkThreadsAnalyzer.cc.

Referenced by analyze(), and runOnOtherThread().

◆ m_mutex

std::mutex edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_mutex
private

◆ m_serviceToken

edm::ServiceToken* edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_serviceToken = nullptr
private

Definition at line 41 of file TestServicesOnNonFrameworkThreadsAnalyzer.cc.

Referenced by analyze(), and runOnOtherThread().

◆ m_streamID

edm::StreamID edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_streamID
private

Definition at line 42 of file TestServicesOnNonFrameworkThreadsAnalyzer.cc.

Referenced by analyze(), and runOnOtherThread().

◆ m_thread

std::unique_ptr<std::thread> edmtest::TestServicesOnNonFrameworkThreadsAnalyzer::m_thread
private