Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:36

0001 //
0002 // Created by davidl on 11/9/22.
0003 //
0004 
0005 #pragma once
0006 
0007 #include <JANA/Utils/JCallGraphRecorder.h>
0008 #include <JANA/JFactory.h>
0009 
0010 /// Stack object to handle recording entry to call graph
0011 ///
0012 /// This is used to add a new entry to a JCallGraph, recording the time when it is created
0013 /// and then again when it is deleted. The intent is to use it as a local stack variable
0014 /// so if the call being timed throws an exception, the destructor of this will still get
0015 /// run, guaranteeing the call stack entry is completed.
0016 ///
0017 /// Objects of this type are used in JEvent::Get and JEventProcessingArrow::execute
0018 /// (and possibly other places).
0019 class JCallGraphEntryMaker{
0020 public:
0021 
0022     JCallGraphEntryMaker(JCallGraphRecorder &callgraphrecorder, JFactory *factory) : m_call_graph(callgraphrecorder), m_factory(factory){
0023         m_call_graph.StartFactoryCall(m_factory->GetObjectName(), m_factory->GetTag());
0024     }
0025 
0026     JCallGraphEntryMaker(JCallGraphRecorder &callgraphrecorder, std::string name) : m_call_graph(callgraphrecorder) {
0027         // This is used mainly for JEventProcessors
0028         m_call_graph.StartFactoryCall(name, "");
0029     }
0030 
0031     ~JCallGraphEntryMaker(){
0032         m_call_graph.FinishFactoryCall( m_factory ? m_factory->GetDataSource():JCallGraphRecorder::DATA_NOT_AVAILABLE );
0033     }
0034 
0035 protected:
0036     JCallGraphRecorder &m_call_graph;
0037     JFactory *m_factory=nullptr;
0038 };
0039 
0040