All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IOBoundAlgTask.cpp
Go to the documentation of this file.
1 #include <functional>
2 
3 // Framework
8 #include "IOBoundAlgTask.h"
9 
10 // local includes
11 #include "RetCodeGuard.h"
12 
14 
15  IAlgorithm *ialg = m_algorithm.get();
16  Algorithm* this_algo = dynamic_cast<Algorithm*>(ialg);
17  if (!this_algo){
18  throw GaudiException ("Cast to Algorithm failed!","AlgoExecutionTask",
20  }
21 
22  bool eventfailed=false;
23  this_algo->setContext(m_evtCtx);
25 
26  m_schedSvc->addAlg(this_algo, m_evtCtx, pthread_self());
27 
28  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
30 
32  MsgStream log(messageSvc, "AccelAlgoExecutionTask");
33 
35  try {
37  log << MSG::DEBUG << "Starting execution of algorithm " << m_algorithm->name()
38  << endmsg;
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  log << MSG::DEBUG << "Stopped execution of algorithm " << m_algorithm->name()
46  << endmsg;
47  rcg.ignore(); // disarm the guard
48  } catch ( const GaudiException& Exception ) {
49  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag()
50  << " thrown by " << m_algorithm->name() << endmsg;
51  log << MSG::ERROR << Exception << endmsg;
52  eventfailed = true;
53  } catch ( const std::exception& Exception ) {
54  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by "
55  << m_algorithm->name() << endmsg;
56  log << MSG::ERROR << Exception.what() << endmsg;
57  eventfailed = true;
58  } catch(...) {
59  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by "
60  << m_algorithm->name() << endmsg;
61  eventfailed = true;
62  }
63 
64  // Commit all DataHandles
65  this_algo->commitHandles();
66 
67  // DP it is important to propagate the failure of an event.
68  // We need to stop execution when this happens so that execute run can
69  // then receive the FAILURE
72  m_aess->updateEventStatus(eventfailed,*m_evtCtx);
73 
74 
75  // Push in the scheduler queue an action to be performed
76  auto action_promote2Executed = std::bind(&ForwardSchedulerSvc::promoteToAsyncExecuted,
77  m_schedSvc,
79  m_evtCtx->slot(),
81  m_evtCtx);
82 
83  // TODO Expose a method to push actions in IScheduler?
84  m_schedSvc->m_actionsQueue.push(action_promote2Executed);
85 
86  m_schedSvc->delAlg(this_algo);
87 
89 
90  return sc;
91 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
SmartIF< IAlgorithm > m_algorithm
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
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
EventContext * m_evtCtx
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< ForwardSchedulerSvc > m_schedSvc
StatusCode promoteToAsyncExecuted(unsigned int iAlgo, int si, IAlgorithm *algo, EventContext *)
The call to this method is triggered only from within the IOBoundAlgTask.
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)
virtual StatusCode execute() override
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
SmartIF< ISvcLocator > m_serviceLocator
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.
const unsigned int m_algoIndex
IAlgExecStateSvc * m_aess
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
GAUDI_API void setCurrentContextEvt(long int evtN)
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