The Gaudi Framework  v30r3 (a5ef0a68)
IOBoundAlgTask Class Reference

Wrapper around I/O-bound Gaudi-algorithms. More...

#include <GaudiHive/src/IOBoundAlgTask.h>

Inheritance diagram for IOBoundAlgTask:
Collaboration diagram for IOBoundAlgTask:

Public Member Functions

 IOBoundAlgTask (IAlgorithm *algorithm, EventContext *ctx, ISvcLocator *svcLocator, IAlgExecStateSvc *aem, std::function< StatusCode()> promote2ExecutedClosure)
 
StatusCode execute () override final
 
- Public Member Functions inherited from IAlgTask
virtual ~IAlgTask ()=default
 

Private Attributes

SmartIF< IAlgorithmm_algorithm
 
EventContextm_evtCtx
 
IAlgExecStateSvcm_aess
 
SmartIF< ISvcLocatorm_serviceLocator
 
std::function< StatusCode()> m_promote2ExecutedClosure
 

Detailed Description

Wrapper around I/O-bound Gaudi-algorithms.

It may also cover the accelerator-targeted algorithms. It must be used to prepare algorithms before sending them to I/O-bound scheduler.

Author
Illya Shapoval
Version
1.0

Definition at line 23 of file IOBoundAlgTask.h.

Constructor & Destructor Documentation

IOBoundAlgTask::IOBoundAlgTask ( IAlgorithm algorithm,
EventContext ctx,
ISvcLocator svcLocator,
IAlgExecStateSvc aem,
std::function< StatusCode()>  promote2ExecutedClosure 
)
inline

Definition at line 26 of file IOBoundAlgTask.h.

28  : m_algorithm( algorithm )
29  , m_evtCtx( ctx )
30  , m_aess( aem )
31  , m_serviceLocator( svcLocator )
32  , m_promote2ExecutedClosure( std::move( promote2ExecutedClosure ) )
33  {
34  }
SmartIF< IAlgorithm > m_algorithm
EventContext * m_evtCtx
SmartIF< ISvcLocator > m_serviceLocator
T move(T...args)
IAlgExecStateSvc * m_aess
std::function< StatusCode()> m_promote2ExecutedClosure

Member Function Documentation

StatusCode IOBoundAlgTask::execute ( )
finaloverridevirtual

Implements IAlgTask.

Definition at line 11 of file IOBoundAlgTask.cpp.

12 {
13 
14  IAlgorithm* ialg = m_algorithm.get();
15  Algorithm* this_algo = dynamic_cast<Algorithm*>( ialg );
16  if ( !this_algo ) {
17  throw GaudiException( "Cast to Algorithm failed!", "AlgoExecutionTask", StatusCode::FAILURE );
18  }
19 
20  bool eventfailed = false;
22 
23  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
24  const SmartIF<IProperty> appmgr( m_serviceLocator );
25 
27  MsgStream log( messageSvc, "AccelAlgoExecutionTask" );
28 
29  // select the appropriate store
30  this_algo->whiteboard()->selectStore( m_evtCtx->valid() ? m_evtCtx->slot() : 0 ).ignore();
31 
33  try {
35  log << MSG::DEBUG << "Starting execution of algorithm " << m_algorithm->name() << endmsg;
37  if ( UNLIKELY( !sc.isSuccess() ) ) {
38  log << MSG::WARNING << "Execution of algorithm " << m_algorithm->name() << " failed" << endmsg;
39  eventfailed = true;
40  }
41  log << MSG::DEBUG << "Stopped execution of algorithm " << m_algorithm->name() << endmsg;
42  rcg.ignore(); // disarm the guard
43  } catch ( const GaudiException& Exception ) {
44  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag() << " thrown by "
45  << m_algorithm->name() << endmsg;
46  log << MSG::ERROR << Exception << endmsg;
47  eventfailed = true;
48  } catch ( const std::exception& Exception ) {
49  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by " << m_algorithm->name() << endmsg;
50  log << MSG::ERROR << Exception.what() << endmsg;
51  eventfailed = true;
52  } catch ( ... ) {
53  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by " << m_algorithm->name() << endmsg;
54  eventfailed = true;
55  }
56 
57  // DP it is important to propagate the failure of an event.
58  // We need to stop execution when this happens so that execute run can
59  // then receive the FAILURE
60  m_aess->updateEventStatus( eventfailed, *m_evtCtx );
61 
62  // update scheduler state
64 
66 
67  return sc;
68 }
#define UNLIKELY(x)
Definition: Kernel.h:122
constexpr static const auto FAILURE
Definition: StatusCode.h:88
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
ContextID_t slot() const
Definition: EventContext.h:40
EventContext * m_evtCtx
constexpr int UnhandledException
Definition: AppReturnCode.h:29
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given &#39;slot&#39; for all subsequent calls within the same thread id.
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
virtual StatusCode sysExecute(const EventContext &)=0
System execution. This method invokes the execute() method of a concrete algorithm.
SmartIF< ISvcLocator > m_serviceLocator
virtual const std::string & tag() const
name tag for the exception, or exception type
STL class.
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
GAUDI_API void setCurrentContext(const EventContext *ctx)
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:832
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)
std::function< StatusCode()> m_promote2ExecutedClosure
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
bool valid() const
Definition: EventContext.h:41

Member Data Documentation

IAlgExecStateSvc* IOBoundAlgTask::m_aess
private

Definition at line 41 of file IOBoundAlgTask.h.

SmartIF<IAlgorithm> IOBoundAlgTask::m_algorithm
private

Definition at line 39 of file IOBoundAlgTask.h.

EventContext* IOBoundAlgTask::m_evtCtx
private

Definition at line 40 of file IOBoundAlgTask.h.

std::function<StatusCode()> IOBoundAlgTask::m_promote2ExecutedClosure
private

Definition at line 43 of file IOBoundAlgTask.h.

SmartIF<ISvcLocator> IOBoundAlgTask::m_serviceLocator
private

Definition at line 42 of file IOBoundAlgTask.h.


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