| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

IOBoundAlgTask.cpp
Go to the documentation of this file.
1 // local includes
2 #include "IOBoundAlgTask.h"
3 #include "RetCodeGuard.h"
4
5 // Framework
6 #include "GaudiKernel/Algorithm.h"
7 #include "GaudiKernel/IMessageSvc.h"
8 #include "GaudiKernel/IProperty.h"
9 #include "GaudiKernel/ContextSpecificPtr.h"
10
11 #include <functional>
12
13 StatusCode IOBoundAlgTask::execute() {
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",
19 StatusCode::FAILURE);
20 }
21
22 bool eventfailed=false;
23 Gaudi::Hive::setCurrentContext( m_evtCtx );
24
25 // TODO reproduce the commented out functionality in a different service
26 //m_schedSvc->addAlg(this_algo, m_evtCtx, pthread_self());
27
28 // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
29 const SmartIF<IProperty> appmgr(m_serviceLocator);
30
31 SmartIF<IMessageSvc> messageSvc (m_serviceLocator);
32 MsgStream log(messageSvc, "AccelAlgoExecutionTask");
33
34 // select the appropriate store
35 this_algo->whiteboard()->selectStore(m_evtCtx->valid() ?
36 m_evtCtx->slot() : 0).ignore();
37
38 StatusCode sc(StatusCode::FAILURE);
39 try {
40 RetCodeGuard rcg(appmgr, Gaudi::ReturnCode::UnhandledException);
41 log << MSG::DEBUG << "Starting execution of algorithm " << m_algorithm->name()
42 << endmsg;
43 sc = m_algorithm->sysExecute(*m_evtCtx);
44 if (UNLIKELY(!sc.isSuccess())) {
45 log << MSG::WARNING << "Execution of algorithm "
46 << m_algorithm->name() << " failed" << endmsg;
47 eventfailed = true;
48 }
49 log << MSG::DEBUG << "Stopped execution of algorithm " << m_algorithm->name()
50 << endmsg;
51 rcg.ignore(); // disarm the guard
52 } catch ( const GaudiException& Exception ) {
53 log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag()
54 << " thrown by " << m_algorithm->name() << endmsg;
55 log << MSG::ERROR << Exception << endmsg;
56 eventfailed = true;
57 } catch ( const std::exception& Exception ) {
58 log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by "
59 << m_algorithm->name() << endmsg;
60 log << MSG::ERROR << Exception.what() << endmsg;
61 eventfailed = true;
62 } catch(...) {
63 log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by "
64 << m_algorithm->name() << endmsg;
65 eventfailed = true;
66 }
67
68 // Commit all DataHandles
69 this_algo->commitHandles();
70
71 // DP it is important to propagate the failure of an event.
72 // We need to stop execution when this happens so that execute run can
73 // then receive the FAILURE
74 m_aess->algExecState(ialg,*m_evtCtx).setExecuted(true);
75 m_aess->algExecState(ialg,*m_evtCtx).setExecStatus(sc);
76 m_aess->updateEventStatus(eventfailed,*m_evtCtx);
77
78 // TODO reproduce the commented out functionality in a different service
79 //m_schedSvc->delAlg(this_algo);
80
81 Gaudi::Hive::setCurrentContextEvt(-1);
82
83 return sc;
84 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Algorithm.h
SmartIF< IProperty >
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
IOBoundAlgTask::m_algorithm
SmartIF< IAlgorithm > m_algorithm
Definition: IOBoundAlgTask.h:39
RetCodeGuard
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:9
Algorithm::commitHandles
void commitHandles() override
Definition: Algorithm.cpp:937
StatusCode::FAILURE
Definition: StatusCode.h:29
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
IOBoundAlgTask::m_evtCtx
EventContext * m_evtCtx
Definition: IOBoundAlgTask.h:40
AlgExecState::setExecStatus
void setExecStatus(const StatusCode &sc=StatusCode::SUCCESS)
Definition: IAlgExecStateSvc.h:39
MSG::DEBUG
Definition: IMessageSvc.h:18
IOBoundAlgTask.h
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:126
Gaudi::ReturnCode::UnhandledException
constexpr int UnhandledException
Definition: AppReturnCode.h:29
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
MSG::FATAL
Definition: IMessageSvc.h:22
IOBoundAlgTask::execute
virtual StatusCode execute() override
Definition: IOBoundAlgTask.cpp:13
IHiveWhiteBoard::selectStore
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given &#39;slot&#39; for all subsequent calls within the same thread id.
std::exception::what
T what(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ContextSpecificPtr.h
IAlgExecStateSvc::algExecState
virtual const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const =0
IAlgorithm::sysExecute
virtual StatusCode sysExecute(const EventContext &)=0
System execution. This method invokes the execute() method of a concrete algorithm.
IOBoundAlgTask::m_serviceLocator
SmartIF< ISvcLocator > m_serviceLocator
Definition: IOBoundAlgTask.h:43
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:119
IMessageSvc.h
AlgExecState::setExecuted
void setExecuted(bool e=true)
Definition: IAlgExecStateSvc.h:38
std::exception
STL class.
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
Gaudi::Hive::setCurrentContext
GAUDI_API void setCurrentContext(const EventContext *ctx)
Definition: ThreadLocalContext.cpp:45
IAlgExecStateSvc::updateEventStatus
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
Algorithm::whiteboard
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:785
IOBoundAlgTask::m_aess
IAlgExecStateSvc * m_aess
Definition: IOBoundAlgTask.h:42
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
IProperty.h
RetCodeGuard.h
Gaudi::Hive::setCurrentContextEvt
GAUDI_API void setCurrentContextEvt(long int evtN)
Definition: ThreadLocalContext.cpp:28
MSG::ERROR
Definition: IMessageSvc.h:21
RetCodeGuard::ignore
void ignore()
Definition: RetCodeGuard.h:13
MSG::WARNING
Definition: IMessageSvc.h:20
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi.Configuration.log
log
Definition: Configuration.py:13
EventContext::valid
bool valid() const
Definition: EventContext.h:42