The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
AlgTask Class Reference

#include </builds/gaudi/Gaudi/GaudiHive/src/AlgTask.h>

Collaboration diagram for AlgTask:

Public Member Functions

 AlgTask (AvalancheSchedulerSvc *scheduler, ISvcLocator *svcLocator, IAlgExecStateSvc *aem, bool asynchronous)
 
void operator() () const
 

Private Attributes

AvalancheSchedulerSvcm_scheduler
 
IAlgExecStateSvcm_aess
 
SmartIF< ISvcLocatorm_serviceLocator
 
bool m_asynchronous { false }
 

Detailed Description

Definition at line 35 of file AlgTask.h.

Constructor & Destructor Documentation

◆ AlgTask()

AlgTask::AlgTask ( AvalancheSchedulerSvc * scheduler,
ISvcLocator * svcLocator,
IAlgExecStateSvc * aem,
bool asynchronous )
inline

Definition at line 37 of file AlgTask.h.

38 : m_scheduler( scheduler ), m_aess( aem ), m_serviceLocator( svcLocator ), m_asynchronous( asynchronous ) {}
AvalancheSchedulerSvc * m_scheduler
Definition AlgTask.h:116
IAlgExecStateSvc * m_aess
Definition AlgTask.h:117
SmartIF< ISvcLocator > m_serviceLocator
Definition AlgTask.h:118
bool m_asynchronous
Definition AlgTask.h:120

Member Function Documentation

◆ operator()()

void AlgTask::operator() ( ) const
inline

Definition at line 40 of file AlgTask.h.

40 {
41
42 SmartIF<IMessageSvc> messageSvc( m_serviceLocator );
43 MsgStream log( messageSvc, "AlgTask" );
44
45 // Get task specification dynamically if it was not provided statically
46 AvalancheSchedulerSvc::TaskSpec ts;
47 log << MSG::DEBUG << "Getting taskspec for " << ( m_asynchronous ? "asynchronous" : "standard" ) << " algorithm"
48 << endmsg;
49 if ( !m_scheduler->next( ts, m_asynchronous ) ) {
50 log << MSG::WARNING << "Missing specification while task is running" << endmsg;
51 return;
52 }
53
54 EventContext& evtCtx = *( ts.contextPtr );
55 IAlgorithm*& iAlgoPtr = ts.algPtr;
56
57 Gaudi::Algorithm* this_algo = dynamic_cast<Gaudi::Algorithm*>( iAlgoPtr );
58 if ( !this_algo ) { throw GaudiException( "Cast to Algorithm failed!", "AlgTask", StatusCode::FAILURE ); }
59
60 bool eventfailed = false;
62
63 // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
64 const SmartIF<IProperty> appmgr( m_serviceLocator );
65
67 log << MSG::DEBUG << "New thread detected: 0x" << std::hex << pthread_self() << std::dec
68 << ". Doing thread local initialization." << endmsg;
69 if ( SmartIF<IThreadPoolSvc> tps{ m_serviceLocator->service( "ThreadPoolSvc" ) } ) {
70 tps->initThisThread();
71 } else {
72 log << MSG::ERROR << "Unable to get the ThreadPoolSvc to trigger thread local initialization" << endmsg;
73 throw GaudiException( "Retrieval of ThreadPoolSvc failed", "AlgTask", StatusCode::FAILURE );
74 }
75 }
76
77 // select the appropriate store
78 this_algo->whiteboard()->selectStore( evtCtx.valid() ? evtCtx.slot() : 0 ).ignore();
79 try {
80 RetCodeGuard rcg( appmgr, Gaudi::ReturnCode::UnhandledException );
81
82 if ( iAlgoPtr->sysExecute( evtCtx ).isFailure() ) {
83 log << MSG::WARNING << "Execution of algorithm " << ts.algName << " failed" << endmsg;
84 eventfailed = true;
85 }
86 rcg.ignore(); // disarm the guard
87 } catch ( const GaudiException& Exception ) {
88 log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag() << " thrown by " << ts.algName
89 << endmsg;
91 eventfailed = true;
92 } catch ( const std::exception& Exception ) {
93 log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by " << ts.algName << endmsg;
94 log << MSG::ERROR << Exception.what() << endmsg;
95 eventfailed = true;
96 } catch ( ... ) {
97 log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by " << ts.algName << endmsg;
98 eventfailed = true;
99 }
100
101 // A FAILURE in algorithm execution must be communicated to the framework
102 m_aess->updateEventStatus( eventfailed, evtCtx );
103
104 // Release algorithm
105 m_scheduler->m_algResourcePool->releaseAlgorithm( ts.algName, iAlgoPtr ).ignore();
106
107 // schedule a sign-off of the Algorithm execution
108 m_scheduler->m_actionsQueue.push(
109 [schdlr = this->m_scheduler, ts = std::move( ts )]() { return schdlr->signoff( ts ); } );
110
112 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
ContextID_t slot() const
bool valid() const
SmartIF< IHiveWhiteBoard > & whiteboard() const
virtual StatusCode sysExecute(const EventContext &)=0
System execution. This method invokes the execute() method of a concrete algorithm.
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given 'slot' for all subsequent calls within the same thread id.
bool isFailure() const
Definition StatusCode.h:129
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139
constexpr static const auto FAILURE
Definition StatusCode.h:100
constexpr int UnhandledException
thread_local bool ThreadInitDone
GAUDI_API void setCurrentContextEvt(long int evtN)
GAUDI_API void setCurrentContext(const EventContext *ctx)
@ WARNING
Definition IMessageSvc.h:22
@ FATAL
Definition IMessageSvc.h:22
@ DEBUG
Definition IMessageSvc.h:22
@ ERROR
Definition IMessageSvc.h:22

Member Data Documentation

◆ m_aess

IAlgExecStateSvc* AlgTask::m_aess
private

Definition at line 117 of file AlgTask.h.

◆ m_asynchronous

bool AlgTask::m_asynchronous { false }
private

Definition at line 120 of file AlgTask.h.

120{ false };

◆ m_scheduler

AvalancheSchedulerSvc* AlgTask::m_scheduler
private

Definition at line 116 of file AlgTask.h.

◆ m_serviceLocator

SmartIF<ISvcLocator> AlgTask::m_serviceLocator
private

Definition at line 118 of file AlgTask.h.


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