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;
24 
25  m_schedSvc->addAlg(this_algo, m_evtCtx, pthread_self());
26 
27  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
29 
31  MsgStream log(messageSvc, "AccelAlgoExecutionTask");
32 
34  try {
36  log << MSG::DEBUG << "Starting execution of algorithm " << m_algorithm->name()
37  << endmsg;
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  log << MSG::DEBUG << "Stopped execution of algorithm " << m_algorithm->name()
45  << endmsg;
46  rcg.ignore(); // disarm the guard
47  } catch ( const GaudiException& Exception ) {
48  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag()
49  << " thrown by " << m_algorithm->name() << endmsg;
50  log << MSG::ERROR << Exception << endmsg;
51  eventfailed = true;
52  } catch ( const std::exception& Exception ) {
53  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by "
54  << m_algorithm->name() << endmsg;
55  log << MSG::ERROR << Exception.what() << endmsg;
56  eventfailed = true;
57  } catch(...) {
58  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by "
59  << m_algorithm->name() << endmsg;
60  eventfailed = true;
61  }
62 
63  // Commit all DataHandles
64  this_algo->commitHandles();
65 
66  // DP it is important to propagate the failure of an event.
67  // We need to stop execution when this happens so that execute run can
68  // then receive the FAILURE
71  m_aess->updateEventStatus(eventfailed,*m_evtCtx);
72 
73 
74  // Push in the scheduler queue an action to be performed
75  auto action_promote2Executed = std::bind(&ForwardSchedulerSvc::promoteToAsyncExecuted,
76  m_schedSvc,
78  m_evtCtx->slot(),
80  m_evtCtx);
81 
82  // TODO Expose a method to push actions in IScheduler?
83  m_schedSvc->m_actionsQueue.push(action_promote2Executed);
84 
85  m_schedSvc->delAlg(this_algo);
86 
88 
89  return sc;
90 }
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:949
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
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.
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
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