| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Private Attributes | List of all members
AlgoExecutionTask Class Reference

`#include <src/AlgoExecutionTask.h>`

Inheritance diagram for AlgoExecutionTask:
[legend]
Collaboration diagram for AlgoExecutionTask:
[legend]

## Public Member Functions
| AlgoExecutionTask (IAlgorithm *algorithm, const EventContext &ctx, ISvcLocator *svcLocator, IAlgExecStateSvc *aem, std::function< StatusCode()> promote2ExecutedClosure)
tbb::task * | execute () override

## Private Attributes
SmartIF< IAlgorithm > | m_algorithm
const EventContext & | m_evtCtx
IAlgExecStateSvc * | m_aess
SmartIF< ISvcLocator > | m_serviceLocator
std::function< StatusCode()> | m_promote2ExecutedClosure

## Detailed Description

Definition at line 14 of file AlgoExecutionTask.h.

## Constructor & Destructor Documentation

## ◆ AlgoExecutionTask()

AlgoExecutionTask::AlgoExecutionTask | ( | IAlgorithm * | algorithm,
|  | const EventContext & | ctx,
|  | ISvcLocator * | svcLocator,
|  | IAlgExecStateSvc * | aem,
|  | std::function< StatusCode()> | promote2ExecutedClosure
| ) |  |
| inline

Definition at line 16 of file AlgoExecutionTask.h.

18 : m_algorithm( algorithm )
19 , m_evtCtx( ctx )
20 , m_aess( aem )
21 , m_serviceLocator( svcLocator )
22 , m_promote2ExecutedClosure( std::move( promote2ExecutedClosure ) ){};
AlgoExecutionTask::m_evtCtx
const EventContext & m_evtCtx
Definition: AlgoExecutionTask.h:27
AlgoExecutionTask::m_aess
IAlgExecStateSvc * m_aess
Definition: AlgoExecutionTask.h:28
AlgoExecutionTask::m_serviceLocator
SmartIF< ISvcLocator > m_serviceLocator
Definition: AlgoExecutionTask.h:29
AlgoExecutionTask::m_algorithm
SmartIF< IAlgorithm > m_algorithm
Definition: AlgoExecutionTask.h:26
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
std::move
T move(T... args)
AlgoExecutionTask::m_promote2ExecutedClosure
std::function< StatusCode()> m_promote2ExecutedClosure
Definition: AlgoExecutionTask.h:30

## Member Function Documentation

## ◆ execute()

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

Definition at line 21 of file AlgoExecutionTask.cpp.

21 {
22
23 IAlgorithm* ialg = m_algorithm.get();
24 Gaudi::Algorithm* this_algo = dynamic_cast<Gaudi::Algorithm*>( ialg );
25 if ( !this_algo ) { throw GaudiException( "Cast to Algorithm failed!", "AlgoExecutionTask", StatusCode::FAILURE ); }
26
27 bool eventfailed = false;
28 Gaudi::Hive::setCurrentContext( m_evtCtx );
29
30 // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
31 const SmartIF<IProperty> appmgr( m_serviceLocator );
32
33 SmartIF<IMessageSvc> messageSvc( m_serviceLocator );
34 MsgStream log( messageSvc, "AlgoExecutionTask" );
35
36 if ( !Gaudi::Concurrency::ThreadInitDone ) {
37 log << MSG::DEBUG << "New thread detected: 0x" << std::hex << pthread_self() << std::dec
38 << ". Doing thread local initialization." << endmsg;
39 SmartIF<IThreadPoolSvc> tps;
40 tps = m_serviceLocator->service( "ThreadPoolSvc" );
41 if ( !tps.isValid() ) {
42 log << MSG::ERROR << "unable to get the ThreadPoolSvc to trigger thread local initialization" << endmsg;
43 throw GaudiException( "retrieval of ThrePoolSvc failed", "AlgoExecutionTask", StatusCode::FAILURE );
44 }
45
46 tps->initThisThread();
47 }
48
49 // select the appropriate store
50 this_algo->whiteboard()->selectStore( m_evtCtx.valid() ? m_evtCtx.slot() : 0 ).ignore();
51
52 StatusCode sc( StatusCode::FAILURE );
53 try {
54 RetCodeGuard rcg( appmgr, Gaudi::ReturnCode::UnhandledException );
55 sc = m_algorithm->sysExecute( m_evtCtx );
56 if ( UNLIKELY( !sc.isSuccess() ) ) {
57 log << MSG::WARNING << "Execution of algorithm " << m_algorithm->name() << " failed" << endmsg;
58 eventfailed = true;
59 }
60 rcg.ignore(); // disarm the guard
61 } catch ( const GaudiException& Exception ) {
62 log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag() << " thrown by "
63 << m_algorithm->name() << endmsg;
64 log << MSG::ERROR << Exception << endmsg;
65 eventfailed = true;
66 } catch ( const std::exception& Exception ) {
67 log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by " << m_algorithm->name() << endmsg;
68 log << MSG::ERROR << Exception.what() << endmsg;
69 eventfailed = true;
70 } catch ( ... ) {
71 log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by " << m_algorithm->name() << endmsg;
72 eventfailed = true;
73 }
74
75 // DP it is important to propagate the failure of an event.
76 // We need to stop execution when this happens so that execute run can
77 // then receive the FAILURE
78 m_aess->updateEventStatus( eventfailed, m_evtCtx );
79
80 // update scheduler state
81 m_promote2ExecutedClosure();
82
83 Gaudi::Hive::setCurrentContextEvt( -1 );
84
85 return nullptr;
86 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:96
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IProperty >
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
RetCodeGuard
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:9
AlgoExecutionTask::m_evtCtx
const EventContext & m_evtCtx
Definition: AlgoExecutionTask.h:27
AlgoExecutionTask::m_aess
IAlgExecStateSvc * m_aess
Definition: AlgoExecutionTask.h:28
Gaudi::Algorithm::whiteboard
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:687
AlgoExecutionTask::m_serviceLocator
SmartIF< ISvcLocator > m_serviceLocator
Definition: AlgoExecutionTask.h:29
MSG::DEBUG
Definition: IMessageSvc.h:15
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:67
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:62
AlgoExecutionTask::m_algorithm
SmartIF< IAlgorithm > m_algorithm
Definition: AlgoExecutionTask.h:26
IThreadPoolSvc::initThisThread
virtual void initThisThread()=0
Do thread local initialization of current thread.
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
EventContext::valid
bool valid() const
Definition: EventContext.h:44
Gaudi::ReturnCode::UnhandledException
constexpr int UnhandledException
Definition: AppReturnCode.h:27
MSG::FATAL
Definition: IMessageSvc.h:15
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
IHiveWhiteBoard::selectStore
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given 'slot' 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:50
IAlgorithm::sysExecute
virtual StatusCode sysExecute(const EventContext &)=0
System execution. This method invokes the execute() method of a concrete algorithm.
std::exception
STL class.
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
Gaudi::Hive::setCurrentContext
GAUDI_API void setCurrentContext(const EventContext *ctx)
Definition: ThreadLocalContext.cpp:31
IAlgExecStateSvc::updateEventStatus
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
Gaudi::Concurrency::ThreadInitDone
thread_local bool ThreadInitDone
Definition: ThreadInitTask.cpp:12
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Gaudi::Hive::setCurrentContextEvt
GAUDI_API void setCurrentContextEvt(long int evtN)
Definition: ThreadLocalContext.cpp:22
std::hex
T hex(T... args)
MSG::ERROR
Definition: IMessageSvc.h:15
MSG::WARNING
Definition: IMessageSvc.h:15
AlgoExecutionTask::m_promote2ExecutedClosure
std::function< StatusCode()> m_promote2ExecutedClosure
Definition: AlgoExecutionTask.h:30
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## Member Data Documentation

## ◆ m_aess

IAlgExecStateSvc* AlgoExecutionTask::m_aess
| private

Definition at line 28 of file AlgoExecutionTask.h.

## ◆ m_algorithm

SmartIF<IAlgorithm> AlgoExecutionTask::m_algorithm
| private

Definition at line 26 of file AlgoExecutionTask.h.

## ◆ m_evtCtx

const EventContext& AlgoExecutionTask::m_evtCtx
| private

Definition at line 27 of file AlgoExecutionTask.h.

## ◆ m_promote2ExecutedClosure

std::function<StatusCode()> AlgoExecutionTask::m_promote2ExecutedClosure
| private

Definition at line 30 of file AlgoExecutionTask.h.

## ◆ m_serviceLocator

SmartIF<ISvcLocator> AlgoExecutionTask::m_serviceLocator
| private

Definition at line 29 of file AlgoExecutionTask.h.

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

- GaudiHive/src/AlgoExecutionTask.h
- GaudiHive/src/AlgoExecutionTask.cpp