All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AlgoExecutionTask.cpp
Go to the documentation of this file.
1 // Framework
2 #include "AlgoExecutionTask.h"
8 
9 // C++
10 #include <functional>
11 
12 // local includes
13 #include "RetCodeGuard.h"
14 
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;
25  this_algo->setContext(m_evtCtx);
27 
28  m_schedSvc->addAlg(this_algo, m_evtCtx, pthread_self());
29 
30  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
32 
34  MsgStream log(messageSvc, "AlgoExecutionTask");
35 
37  try {
39  sc = m_algorithm->sysExecute();
40  if (UNLIKELY(!sc.isSuccess())) {
41  log << MSG::WARNING << "Execution of algorithm "
42  << m_algorithm->name() << " failed" << endmsg;
43  eventfailed = true;
44  }
45  rcg.ignore(); // disarm the guard
46  } catch ( const GaudiException& Exception ) {
47  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag()
48  << " thrown by " << m_algorithm->name() << endmsg;
49  log << MSG::ERROR << Exception << endmsg;
50  eventfailed = true;
51  } catch ( const std::exception& Exception ) {
52  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by "
53  << m_algorithm->name() << endmsg;
54  log << MSG::ERROR << Exception.what() << endmsg;
55  eventfailed = true;
56  } catch(...) {
57  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by "
58  << m_algorithm->name() << endmsg;
59  eventfailed = true;
60  }
61 
62  // Commit all DataHandles
63  this_algo->commitHandles();
64 
65  // DP it is important to propagate the failure of an event.
66  // We need to stop execution when this happens so that execute run can
67  // then receive the FAILURE
70  m_aess->updateEventStatus(eventfailed,*m_evtCtx);
71 
72  // Push in the scheduler queue an action to be performed
73  auto action_promote2Executed = std::bind(&ForwardSchedulerSvc::promoteToExecuted,
74  m_schedSvc,
75  m_algoIndex,
76  m_evtCtx->slot(),
78  m_evtCtx);
79 
80  m_schedSvc->m_actionsQueue.push(action_promote2Executed);
81 
82  m_schedSvc->delAlg(this_algo);
83 
85 
86  return nullptr;
87 }
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:984
ContextID_t slot() const
Definition: EventContext.h:41
IAlgExecStateSvc * m_aess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
SmartIF< ISvcLocator > m_serviceLocator
void setExecStatus(const StatusCode &sc=StatusCode::SUCCESS)
#define UNLIKELY(x)
Definition: Kernel.h:126
void setContext(const EventContext *context) override
set the context
Definition: Algorithm.h:438
SmartIF< IAlgorithm > m_algorithm
virtual StatusCode sysExecute()=0
System execution. This method invokes the execute() method of a concrete algorithm.
tbb::task * execute() override
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.
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
void ignore()
Definition: RetCodeGuard.h:13
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual void updateEventStatus(const bool &b)=0