| The Gaudi Framework v27r1

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

This SchedulerSvc implements the IScheduler interface. More...

`#include <src/SequentialSchedulerSvc.h>`

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

## Public Member Functions
| SequentialSchedulerSvc (const std::string &name, ISvcLocator *svc)
| Constructor. More...
| ~SequentialSchedulerSvc ()
| Destructor. More...
virtual StatusCode | initialize ()
| Initialise. More...
virtual StatusCode | finalize ()
| Finalise. More...
virtual StatusCode | pushNewEvent (EventContext *eventContext)
| Make an event available to the scheduler. More...
virtual StatusCode | pushNewEvents (std::vector< EventContext * > &eventContexts)
virtual StatusCode | popFinishedEvent (EventContext *&eventContext)
| Blocks until an event is availble. More...
virtual StatusCode | tryPopFinishedEvent (EventContext *&eventContext)
| Try to fetch an event from the scheduler. More...
virtual unsigned int | freeSlots ()
| Get free slots number. More...
Public Member Functions inherited from extends< Service, IScheduler >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
StatusCode | setProperty (const Property &p) override
StatusCode | setProperty (const std::string &s) override
StatusCode | setProperty (const std::string &n, const std::string &v) override
StatusCode | getProperty (Property *p) const override
const Property & | getProperty (const std::string &name) const override
StatusCode | getProperty (const std::string &n, std::string &v) const override
const std::vector< Property * > & | getProperties () const override
bool | hasProperty (const std::string &name) const override
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties. More...
template<class T >
StatusCode | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces...>
| ~extend_interfaces () override=default
| Virtual destructor. More...

## Private Attributes
bool | m_useTopAlgList
| Decide if the top alglist or its flat version has to be used. More...
std::list< IAlgorithm * > | m_algList
| Cache the list of algs to be executed. More...
EventContext * | m_eventContext
| The context of the event being processed. More...
int | m_freeSlots
| The number of free slots (0 or 1) More...

## Additional Inherited Members
Public Types inherited from extends< Service, IScheduler >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces...>
| Typedef to the base of this class. More...
Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces...>
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
| take union of the ext_iids of all Interfaces... More...
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel = MSG::NIL
| Service output level. More...
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...

## Detailed Description

This SchedulerSvc implements the IScheduler interface.

It executes all the algorithms in sequence, pulling them from the AlgResourcePool. No task level parallelism is involved. Given its sequential nature, the scheduler does not run in its own thread. It has therefore to be treated a as a THREAD UNSAFE and NON REENTRANT entity.

Author
  Danilo Piparo
  Benedikt Hegner

Version
  1.1

Definition at line 36 of file SequentialSchedulerSvc.h.

## Constructor & Destructor Documentation

SequentialSchedulerSvc::SequentialSchedulerSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc
| ) |  |

Constructor.

Definition at line 23 of file SequentialSchedulerSvc.cpp.

23 :
24 base_class(name,svcLoc),
25 m_eventContext(nullptr),
26 m_freeSlots(1){
27 declareProperty("UseTopAlgList", m_useTopAlgList=true);
28 }
extends< Service, IScheduler >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
SequentialSchedulerSvc::m_freeSlots
int m_freeSlots
The number of free slots (0 or 1)
Definition: SequentialSchedulerSvc.h:79
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
SequentialSchedulerSvc::m_useTopAlgList
bool m_useTopAlgList
Decide if the top alglist or its flat version has to be used.
Definition: SequentialSchedulerSvc.h:70
SequentialSchedulerSvc::m_eventContext
EventContext * m_eventContext
The context of the event being processed.
Definition: SequentialSchedulerSvc.h:76

SequentialSchedulerSvc::~SequentialSchedulerSvc | ( |  | ) |

Destructor.

Definition at line 31 of file SequentialSchedulerSvc.cpp.

31 {}

## Member Function Documentation

StatusCode SequentialSchedulerSvc::finalize | ( |  | ) |
| virtual

Finalise.

Definition at line 57 of file SequentialSchedulerSvc.cpp.

57 {
58 StatusCode sc(Service::finalize());
59 if (!sc.isSuccess())
60 warning () << "Base class could not be finalized" << endmsg;
61 return sc;
62 }
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:193
merge_files.sc
int sc
Definition: merge_files.py:167
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:121
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

unsigned int SequentialSchedulerSvc::freeSlots | ( |  | ) |
| virtual

Get free slots number.

Given that the scheduler is sequential and its methods non reentrant, this is always 1.

Definition at line 173 of file SequentialSchedulerSvc.cpp.

173 {return m_freeSlots;}
SequentialSchedulerSvc::m_freeSlots
int m_freeSlots
The number of free slots (0 or 1)
Definition: SequentialSchedulerSvc.h:79

StatusCode SequentialSchedulerSvc::initialize | ( |  | ) |
| virtual

Initialise.

Definition at line 34 of file SequentialSchedulerSvc.cpp.

34 {
35
36 // Initialise mother class (read properties, ...)
37 StatusCode sc(Service::initialize());
38 if (!sc.isSuccess())
39 warning () << "Base class could not be initialized" << endmsg;
40
41 // Get the algo resource pool
42 SmartIF<IAlgResourcePool> algResourcePool (serviceLocator()->service("AlgResourcePool"));
43 if (!algResourcePool.isValid()){
44 error() << "Error retrieving AlgResourcePool" << endmsg;
45 return StatusCode::FAILURE;
46 }
47
48 // Get the list of algorithms
49 m_algList = m_useTopAlgList ? algResourcePool->getTopAlgList() : algResourcePool->getFlatAlgList();
50 info() << "Found " << m_algList.size() << " algorithms" << endmsg;
51
52 return StatusCode::SUCCESS;
53
54 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:68
SmartIF< IAlgResourcePool >
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
SequentialSchedulerSvc::m_algList
std::list< IAlgorithm * > m_algList
Cache the list of algs to be executed.
Definition: SequentialSchedulerSvc.h:73
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
merge_files.sc
int sc
Definition: merge_files.py:167
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:121
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::list::size
T size(T...args)
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Service.h:144
SequentialSchedulerSvc::m_useTopAlgList
bool m_useTopAlgList
Decide if the top alglist or its flat version has to be used.
Definition: SequentialSchedulerSvc.h:70
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode SequentialSchedulerSvc::popFinishedEvent | ( | EventContext *& | eventContext | ) |
| virtual

Blocks until an event is availble.

Definition at line 154 of file SequentialSchedulerSvc.cpp.

154 {
155 m_freeSlots++;
156 eventContext = m_eventContext;
157 debug() << "[popFinishedEvent] Free slots are now: " << m_freeSlots << endmsg;
158 return StatusCode::SUCCESS;
159 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
SequentialSchedulerSvc::m_freeSlots
int m_freeSlots
The number of free slots (0 or 1)
Definition: SequentialSchedulerSvc.h:79
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SequentialSchedulerSvc::m_eventContext
EventContext * m_eventContext
The context of the event being processed.
Definition: SequentialSchedulerSvc.h:76

StatusCode SequentialSchedulerSvc::pushNewEvent | ( | EventContext * | eventContext | ) |
| virtual

Make an event available to the scheduler.

Immediately the algortihms are executed.

Definition at line 69 of file SequentialSchedulerSvc.cpp.

69 {
70
71 m_freeSlots--;
72
73 debug() << "[pushNewEvent] Free slots are now: " << m_freeSlots << endmsg;
74
75 // Call the resetExecuted() method of ALL "known" algorithms
76 // (From the MinimalEventLoopMgr)
77 SmartIF<IAlgManager> algMan(serviceLocator());
78 if (LIKELY(algMan.isValid())) {
79 for( IAlgorithm* ialg : algMan->getAlgorithms() ) {
80 if (LIKELY(nullptr != ialg)) ialg->resetExecuted();
81 }
82 }
83
84 m_eventContext= eventContext;
85 bool eventfailed=false;
86
87 for (IAlgorithm* ialgorithm : m_algList){
88
89 Algorithm* this_algo = dynamic_cast<Algorithm*>(ialgorithm);
90 if (!this_algo){
91 throw GaudiException ("Cast to Algorithm failed!",
92 "SequentialSchedulerSvc",
93 StatusCode::FAILURE);
94 }
95
96 debug() << "Running algorithm " << this_algo->name() << endmsg;
97
98 // m_eventContext->m_thread_id = pthread_self();
99 this_algo->setContext(m_eventContext);
100
101 // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
102 const SmartIF<IProperty> appmgr(serviceLocator());
103
104 // Call the execute() method of all top algorithms
105 StatusCode sc(StatusCode::FAILURE);
106 try {
107 RetCodeGuard rcg(appmgr, Gaudi::ReturnCode::UnhandledException);
108 sc = ialgorithm->sysExecute();
109 if (UNLIKELY(!sc.isSuccess())) {
110 warning() << "Execution of algorithm " << ialgorithm->name() << " failed" << endmsg;
111 eventfailed = true;
112 }
113 rcg.ignore(); // disarm the guard
114 } catch ( const GaudiException& Exception ) {
115 error() << ".executeEvent(): Exception with tag=" << Exception.tag()
116 << " thrown by " << ialgorithm->name() << endmsg;
117 error() << Exception << endmsg;
118 } catch ( const std::exception& Exception ) {
119 fatal() << ".executeEvent(): Standard std::exception thrown by "
120 << ialgorithm->name() << endmsg;
121 error() << Exception.what() << endmsg;
122 } catch(...) {
123 fatal() << ".executeEvent(): UNKNOWN Exception thrown by "
124 << ialgorithm->name() << endmsg;
125 }
126
127 debug() << "Algorithm " << this_algo->name() << (eventfailed ? " failed" : " succeeded") << endmsg;
128 debug() << "Algorithm " << this_algo->name() << (this_algo->filterPassed() ? " passed" : " rejected") << endmsg;
129
130 // DP it is important to propagate the failure of an event.
131 // We need to stop execution when this happens so that execute run can
132 // then receive the FAILURE
133 m_eventContext->setFail(eventfailed);
134
135 if (eventfailed)
136 return StatusCode::FAILURE;
137 }
138 return StatusCode::SUCCESS;
139
140 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:126
SmartIF< IAlgManager >
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
RetCodeGuard
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:9
SequentialSchedulerSvc::m_algList
std::list< IAlgorithm * > m_algList
Cache the list of algs to be executed.
Definition: SequentialSchedulerSvc.h:73
Algorithm::filterPassed
bool filterPassed() const override
Did this algorithm pass or fail its filter criterion for the last event?
Definition: Algorithm.cpp:857
merge_files.sc
int sc
Definition: merge_files.py:167
Algorithm::setContext
void setContext(EventContext *context)
set the context
Definition: Algorithm.h:574
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
Gaudi::ReturnCode::UnhandledException
constexpr int UnhandledException
Definition: AppReturnCode.h:27
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:121
StatusCode::FAILURE
Definition: StatusCode.h:29
std::exception::what
T what(T...args)
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
EventContext::setFail
void setFail(const bool &b=true)
Definition: EventContext.h:65
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:119
std::exception
STL class.
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
LIKELY
#define LIKELY(x)
Definition: Kernel.h:125
SequentialSchedulerSvc::m_freeSlots
int m_freeSlots
The number of free slots (0 or 1)
Definition: SequentialSchedulerSvc.h:79
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:112
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SequentialSchedulerSvc::m_eventContext
EventContext * m_eventContext
The context of the event being processed.
Definition: SequentialSchedulerSvc.h:76

StatusCode SequentialSchedulerSvc::pushNewEvents | ( | std::vector< EventContext * > & | eventContexts | ) |
| virtual

Definition at line 143 of file SequentialSchedulerSvc.cpp.

143 {
144 StatusCode sc;
145 for (auto context : eventContexts){
146 sc = pushNewEvent(context);
147 if (sc != StatusCode::SUCCESS) return sc;
148 }
149 return sc;
150 }
merge_files.sc
int sc
Definition: merge_files.py:167
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SequentialSchedulerSvc::pushNewEvent
virtual StatusCode pushNewEvent(EventContext *eventContext)
Make an event available to the scheduler.
Definition: SequentialSchedulerSvc.cpp:69

StatusCode SequentialSchedulerSvc::tryPopFinishedEvent | ( | EventContext *& | eventContext | ) |
| virtual

Try to fetch an event from the scheduler.

The scheduler is sequential.

Therefore pop and try/pop are factually the same.

Definition at line 165 of file SequentialSchedulerSvc.cpp.

165 {
166 return m_freeSlots == 1 ? StatusCode::FAILURE : popFinishedEvent(eventContext);
167 }
StatusCode::FAILURE
Definition: StatusCode.h:29
SequentialSchedulerSvc::m_freeSlots
int m_freeSlots
The number of free slots (0 or 1)
Definition: SequentialSchedulerSvc.h:79
SequentialSchedulerSvc::popFinishedEvent
virtual StatusCode popFinishedEvent(EventContext *&eventContext)
Blocks until an event is availble.
Definition: SequentialSchedulerSvc.cpp:154

## Member Data Documentation

std::list<IAlgorithm*> SequentialSchedulerSvc::m_algList
| private

Cache the list of algs to be executed.

Definition at line 73 of file SequentialSchedulerSvc.h.

EventContext* SequentialSchedulerSvc::m_eventContext
| private

The context of the event being processed.

Definition at line 76 of file SequentialSchedulerSvc.h.

int SequentialSchedulerSvc::m_freeSlots
| private

The number of free slots (0 or 1)

Definition at line 79 of file SequentialSchedulerSvc.h.

bool SequentialSchedulerSvc::m_useTopAlgList
| private

Decide if the top alglist or its flat version has to be used.

Definition at line 70 of file SequentialSchedulerSvc.h.

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

- GaudiHive/src/SequentialSchedulerSvc.h
- GaudiHive/src/SequentialSchedulerSvc.cpp