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

#include <AlgTask.h>

Collaboration diagram for AlgTask:

Public Member Functions

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

Private Attributes

AvalancheSchedulerSvc * m_scheduler
IAlgExecStateSvc * m_aess
SmartIF< ISvcLocator > m_serviceLocator
bool m_asynchronous { false }

Detailed Description

Definition at line 38 of file AlgTask.h.

Constructor & Destructor Documentation

◆ AlgTask()

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

Definition at line 40 of file AlgTask.h.

41 : m_scheduler( scheduler ), m_aess( aem ), m_serviceLocator( svcLocator ), m_asynchronous( asynchronous ) {}
AvalancheSchedulerSvc * m_scheduler
Definition AlgTask.h:119
IAlgExecStateSvc * m_aess
Definition AlgTask.h:120
SmartIF< ISvcLocator > m_serviceLocator
Definition AlgTask.h:121
bool m_asynchronous
Definition AlgTask.h:123

Member Function Documentation

◆ operator()()

void AlgTask::operator() ( ) const
inline

Definition at line 43 of file AlgTask.h.

43 {
44
45 SmartIF<IMessageSvc> messageSvc( m_serviceLocator );
46 MsgStream log( messageSvc, "AlgTask" );
47
48 // Get task specification dynamically if it was not provided statically
49 AvalancheSchedulerSvc::TaskSpec ts;
50 log << MSG::DEBUG << "Getting taskspec for " << ( m_asynchronous ? "asynchronous" : "standard" ) << " algorithm"
51 << endmsg;
52 if ( !m_scheduler->next( ts, m_asynchronous ) ) {
53 log << MSG::WARNING << "Missing specification while task is running" << endmsg;
54 return;
55 }
56
57 EventContext& evtCtx = *( ts.contextPtr );
58 IAlgorithm*& iAlgoPtr = ts.algPtr;
59
60 Gaudi::Algorithm* this_algo = dynamic_cast<Gaudi::Algorithm*>( iAlgoPtr );
61 if ( !this_algo ) { throw GaudiException( "Cast to Algorithm failed!", "AlgTask", StatusCode::FAILURE ); }
62
63 bool eventfailed = false;
65
66 // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
67 const SmartIF<IProperty> appmgr( m_serviceLocator );
68
70 log << MSG::DEBUG << "New thread detected: 0x" << std::hex << pthread_self() << std::dec
71 << ". Doing thread local initialization." << endmsg;
72 if ( SmartIF<IThreadPoolSvc> tps{ m_serviceLocator->service( "ThreadPoolSvc" ) } ) {
73 tps->initThisThread();
74 } else {
75 log << MSG::ERROR << "Unable to get the ThreadPoolSvc to trigger thread local initialization" << endmsg;
76 throw GaudiException( "Retrieval of ThreadPoolSvc failed", "AlgTask", StatusCode::FAILURE );
77 }
78 }
79
80 // select the appropriate store
81 this_algo->whiteboard()->selectStore( evtCtx.valid() ? evtCtx.slot() : 0 ).ignore();
82 try {
83 RetCodeGuard rcg( appmgr, Gaudi::ReturnCode::UnhandledException );
84
85 if ( iAlgoPtr->sysExecute( evtCtx ).isFailure() ) {
86 log << MSG::WARNING << "Execution of algorithm " << ts.algName << " failed" << endmsg;
87 eventfailed = true;
88 }
89 rcg.ignore(); // disarm the guard
90 } catch ( const GaudiException& Exception ) {
91 log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag() << " thrown by " << ts.algName
92 << endmsg;
94 eventfailed = true;
95 } catch ( const std::exception& Exception ) {
96 log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by " << ts.algName << endmsg;
97 log << MSG::ERROR << Exception.what() << endmsg;
98 eventfailed = true;
99 } catch ( ... ) {
100 log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by " << ts.algName << endmsg;
101 eventfailed = true;
102 }
103
104 // A FAILURE in algorithm execution must be communicated to the framework
105 m_aess->updateEventStatus( eventfailed, evtCtx );
106
107 // Release algorithm
108 m_scheduler->m_algResourcePool->releaseAlgorithm( ts.algName, iAlgoPtr ).ignore();
109
110 // schedule a sign-off of the Algorithm execution
112 [schdlr = this->m_scheduler, ts = std::move( ts )]() { return schdlr->signoff( ts ); } );
113
115 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
constexpr _OI move(_II __first, _II __last, _OI __result)
ios_base & hex(ios_base &__base)
ios_base & dec(ios_base &__base)
bool next(TaskSpec &ts, bool asynchronous)
tbb::concurrent_bounded_queue< action > m_actionsQueue
Queue where closures are stored and picked for execution.
SmartIF< IAlgResourcePool > m_algResourcePool
Cache for the algorithm resource pool.
ContextID_t slot() const
bool valid() const
SmartIF< IHiveWhiteBoard > & whiteboard() const
GaudiException(std::string Message, std::string Tag, StatusCode Code)
Constructor (1).
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
virtual StatusCode releaseAlgorithm(std::string_view name, IAlgorithm *&algo)=0
Release a certain algorithm.
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.
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
bool isFailure() const
Definition StatusCode.h:118
void ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:128
constexpr static const auto FAILURE
Definition StatusCode.h:100
constexpr int UnhandledException
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 120 of file AlgTask.h.

◆ m_asynchronous

bool AlgTask::m_asynchronous { false }
private

Definition at line 123 of file AlgTask.h.

◆ m_scheduler

AvalancheSchedulerSvc* AlgTask::m_scheduler
private

Definition at line 119 of file AlgTask.h.

◆ m_serviceLocator

SmartIF<ISvcLocator> AlgTask::m_serviceLocator
private

Definition at line 121 of file AlgTask.h.


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