AlgoExecutionTask Class Reference

#include <src/AlgoExecutionTask.h>

Inheritance diagram for AlgoExecutionTask:
Collaboration diagram for AlgoExecutionTask:

Public Member Functions

 AlgoExecutionTask (IAlgorithm *algorithm, unsigned int algoIndex, ISvcLocator *svcLocator, ForwardSchedulerSvc *schedSvc)
 
virtual tbb::task * execute ()
 

Private Attributes

SmartIF< IAlgorithmm_algorithm
 
const unsigned int m_algoIndex
 
SmartIF< ForwardSchedulerSvcm_schedSvc
 
SmartIF< ISvcLocatorm_serviceLocator
 

Detailed Description

Definition at line 14 of file AlgoExecutionTask.h.

Constructor & Destructor Documentation

AlgoExecutionTask::AlgoExecutionTask ( IAlgorithm algorithm,
unsigned int  algoIndex,
ISvcLocator svcLocator,
ForwardSchedulerSvc schedSvc 
)
inline

Definition at line 16 of file AlgoExecutionTask.h.

19  :
20  m_algorithm(algorithm),
21  m_algoIndex(algoIndex),
22  m_schedSvc(schedSvc),
23  m_serviceLocator(svcLocator){};
SmartIF< ISvcLocator > m_serviceLocator
SmartIF< IAlgorithm > m_algorithm
SmartIF< ForwardSchedulerSvc > m_schedSvc
const unsigned int m_algoIndex

Member Function Documentation

tbb::task * AlgoExecutionTask::execute ( )
virtual

Definition at line 14 of file AlgoExecutionTask.cpp.

14  {
15 
16  Algorithm* this_algo = dynamic_cast<Algorithm*>(m_algorithm.get());
17  if (!this_algo){
18  throw GaudiException ("Cast to Algorithm failed!","AlgoExecutionTask",StatusCode::FAILURE);
19  }
20 
21  bool eventfailed=false;
22  EventContext* eventContext = this_algo->getContext();
23  // eventContext->m_thread_id = pthread_self();
24  Gaudi::Hive::setCurrentContext( eventContext );
25 
26  m_schedSvc->addAlg(this_algo, eventContext, pthread_self());
27 
28  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
30 
32  MsgStream log(messageSvc, "AlgoExecutionTask");
33 
35  try {
38  if (UNLIKELY(!sc.isSuccess())) {
39  log << MSG::WARNING << "Execution of algorithm " << m_algorithm->name() << " failed" << endmsg;
40  eventfailed = true;
41  }
42  rcg.ignore(); // disarm the guard
43  } catch ( const GaudiException& Exception ) {
44  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag()
45  << " thrown by " << m_algorithm->name() << endmsg;
46  log << MSG::ERROR << Exception << endmsg;
47  } catch ( const std::exception& Exception ) {
48  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by "
49  << m_algorithm->name() << endmsg;
50  log << MSG::ERROR << Exception.what() << endmsg;
51  } catch(...) {
52  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by "
53  << m_algorithm->name() << endmsg;
54  }
55 
56  // Commit all DataHandles
57  this_algo->commitHandles();
58 
59  // DP it is important to propagate the failure of an event.
60  // We need to stop execution when this happens so that execute run can
61  // then receive the FAILURE
62  eventContext->setFail(eventfailed);
63 
64  // Push in the scheduler queue an action to be performed
65  auto action_promote2Executed = std::bind(&ForwardSchedulerSvc::promoteToExecuted,
66  m_schedSvc,
67  m_algoIndex,
68  eventContext->slot(),
69  m_algorithm);
70 
71  m_schedSvc->m_actionsQueue.push(action_promote2Executed);
72 
73  m_schedSvc->delAlg(this_algo);
74 
76 
77  return nullptr;
78 }
#define UNLIKELY(x)
Definition: Kernel.h:126
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:9
void commitHandles() override
Definition: Algorithm.cpp:1097
ContextID_t slot() const
Definition: EventContext.h:41
SmartIF< ISvcLocator > m_serviceLocator
SmartIF< IAlgorithm > m_algorithm
EventContext * getContext() const
get the context
Definition: Algorithm.h:571
This class represents an entry point to all the event specific data.
Definition: EventContext.h:25
StatusCode promoteToExecuted(unsigned int iAlgo, int si, IAlgorithm *algo)
The call to this method is triggered only from within the AlgoExecutionTask.
virtual StatusCode sysExecute()=0
System execution. This method invokes the execute() method of a concrete algorithm.
constexpr int UnhandledException
Definition: AppReturnCode.h:27
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
void addAlg(Algorithm *, EventContext *, pthread_t)
SmartIF< ForwardSchedulerSvc > m_schedSvc
const unsigned int m_algoIndex
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
void setFail(const bool &b=true)
Definition: EventContext.h:65
virtual const std::string & tag() const
name tag for the exception, or exception type
T bind(T...args)
STL class.
GAUDI_API void setCurrentContext(const EventContext *ctx)
tbb::concurrent_bounded_queue< action > m_actionsQueue
Queue where closures are stored and picked for execution.
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
GAUDI_API void setCurrentContextEvt(long int evtN)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Member Data Documentation

const unsigned int AlgoExecutionTask::m_algoIndex
private

Definition at line 27 of file AlgoExecutionTask.h.

SmartIF<IAlgorithm> AlgoExecutionTask::m_algorithm
private

Definition at line 26 of file AlgoExecutionTask.h.

SmartIF<ForwardSchedulerSvc> AlgoExecutionTask::m_schedSvc
private

Definition at line 29 of file AlgoExecutionTask.h.

SmartIF<ISvcLocator> AlgoExecutionTask::m_serviceLocator
private

Definition at line 30 of file AlgoExecutionTask.h.


The documentation for this class was generated from the following files: