AlgoExecutionTask Class Reference

#include <src/AlgoExecutionTask.h>

Inheritance diagram for AlgoExecutionTask:
Collaboration diagram for AlgoExecutionTask:

Public Member Functions

 AlgoExecutionTask (IAlgorithm *algorithm, unsigned int algoIndex, EventContext *ctx, ISvcLocator *svcLocator, ForwardSchedulerSvc *schedSvc, IAlgExecStateSvc *aem)
 
tbb::task * execute () override
 

Private Attributes

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

Detailed Description

Definition at line 16 of file AlgoExecutionTask.h.

Constructor & Destructor Documentation

AlgoExecutionTask::AlgoExecutionTask ( IAlgorithm algorithm,
unsigned int  algoIndex,
EventContext ctx,
ISvcLocator svcLocator,
ForwardSchedulerSvc schedSvc,
IAlgExecStateSvc aem 
)
inline

Definition at line 18 of file AlgoExecutionTask.h.

23  :
24  m_algorithm(algorithm),
25  m_evtCtx(ctx),
26  m_algoIndex(algoIndex),
27  m_schedSvc(schedSvc),
28  m_aess(aem),
29  m_serviceLocator(svcLocator){};
IAlgExecStateSvc * m_aess
SmartIF< ISvcLocator > m_serviceLocator
SmartIF< IAlgorithm > m_algorithm
SmartIF< ForwardSchedulerSvc > m_schedSvc
const unsigned int m_algoIndex
EventContext * m_evtCtx

Member Function Documentation

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

Definition at line 15 of file AlgoExecutionTask.cpp.

15  {
16 
17  IAlgorithm *ialg = m_algorithm.get();
18  Algorithm* this_algo = dynamic_cast<Algorithm*>(ialg);
19  if (!this_algo){
20  throw GaudiException ("Cast to Algorithm failed!","AlgoExecutionTask",
22  }
23 
24  bool eventfailed=false;
26 
27  m_schedSvc->addAlg(this_algo, m_evtCtx, pthread_self());
28 
29  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
31 
33  MsgStream log(messageSvc, "AlgoExecutionTask");
34 
36  try {
38  sc = m_algorithm->sysExecute();
39  if (UNLIKELY(!sc.isSuccess())) {
40  log << MSG::WARNING << "Execution of algorithm "
41  << m_algorithm->name() << " failed" << endmsg;
42  eventfailed = true;
43  }
44  rcg.ignore(); // disarm the guard
45  } catch ( const GaudiException& Exception ) {
46  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag()
47  << " thrown by " << m_algorithm->name() << endmsg;
48  log << MSG::ERROR << Exception << endmsg;
49  eventfailed = true;
50  } catch ( const std::exception& Exception ) {
51  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by "
52  << m_algorithm->name() << endmsg;
53  log << MSG::ERROR << Exception.what() << endmsg;
54  eventfailed = true;
55  } catch(...) {
56  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by "
57  << m_algorithm->name() << endmsg;
58  eventfailed = true;
59  }
60 
61  // Commit all DataHandles
62  this_algo->commitHandles();
63 
64  // DP it is important to propagate the failure of an event.
65  // We need to stop execution when this happens so that execute run can
66  // then receive the FAILURE
69  m_aess->updateEventStatus(eventfailed,*m_evtCtx);
70 
71  // Push in the scheduler queue an action to be performed
72  auto action_promote2Executed = std::bind(&ForwardSchedulerSvc::promoteToExecuted,
73  m_schedSvc,
74  m_algoIndex,
75  m_evtCtx->slot(),
77  m_evtCtx);
78 
79  m_schedSvc->m_actionsQueue.push(action_promote2Executed);
80 
81  m_schedSvc->delAlg(this_algo);
82 
84 
85  return nullptr;
86 }
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:949
ContextID_t slot() const
Definition: EventContext.h:41
IAlgExecStateSvc * m_aess
SmartIF< ISvcLocator > m_serviceLocator
void setExecStatus(const StatusCode &sc=StatusCode::SUCCESS)
#define UNLIKELY(x)
Definition: Kernel.h:126
SmartIF< IAlgorithm > m_algorithm
virtual StatusCode sysExecute()=0
System execution. This method invokes the execute() method of a concrete algorithm.
constexpr int UnhandledException
Definition: AppReturnCode.h:29
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
virtual const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const =0
StatusCode promoteToExecuted(unsigned int iAlgo, int si, IAlgorithm *algo, EventContext *)
The call to this method is triggered only from within the AlgoExecutionTask.
virtual const std::string & tag() const
name tag for the exception, or exception type
T bind(T...args)
void setExecuted(bool e=true)
STL class.
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
GAUDI_API void setCurrentContext(const EventContext *ctx)
tbb::concurrent_bounded_queue< action > m_actionsQueue
Queue where closures are stored and picked for execution.
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
GAUDI_API void setCurrentContextEvt(long int evtN)
EventContext * m_evtCtx
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Member Data Documentation

IAlgExecStateSvc* AlgoExecutionTask::m_aess
private

Definition at line 37 of file AlgoExecutionTask.h.

const unsigned int AlgoExecutionTask::m_algoIndex
private

Definition at line 34 of file AlgoExecutionTask.h.

SmartIF<IAlgorithm> AlgoExecutionTask::m_algorithm
private

Definition at line 32 of file AlgoExecutionTask.h.

EventContext* AlgoExecutionTask::m_evtCtx
private

Definition at line 33 of file AlgoExecutionTask.h.

SmartIF<ForwardSchedulerSvc> AlgoExecutionTask::m_schedSvc
private

Definition at line 36 of file AlgoExecutionTask.h.

SmartIF<ISvcLocator> AlgoExecutionTask::m_serviceLocator
private

Definition at line 38 of file AlgoExecutionTask.h.


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