1 #ifndef GAUDIHIVE_FORWARDSCHEDULERSVC_H
2 #define GAUDIHIVE_FORWARDSCHEDULERSVC_H
5 #include "GaudiKernel/IScheduler.h"
6 #include "GaudiKernel/IRunable.h"
7 #include "GaudiKernel/Service.h"
8 #include "GaudiKernel/IAlgResourcePool.h"
9 #include "GaudiKernel/IHiveWhiteBoard.h"
20 #include <unordered_map>
25 #include "tbb/concurrent_queue.h"
119 inline unsigned int algname2index(
const std::string& algoname);
125 inline const std::string&
index2algname (
unsigned int index);
195 typedef std::function<StatusCode ()>
action;
218 #endif // GAUDIHIVE_FORWARDSCHEDULERSVC_H
StatusCode deactivate()
Deactivate scheduler.
StatusCode eventFailed(EventContext *eventContext)
Method to check if an event failed and take appropriate actions.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
ForwardSchedulerSvc(const std::string &name, ISvcLocator *svc)
Constructor.
virtual StatusCode initialize()
Initialise.
SmartIF< IAlgResourcePool > m_algResourcePool
Cache for the algorithm resource pool.
virtual StatusCode pushNewEvent(EventContext *eventContext)
Make an event available to the scheduler.
bool m_isActive
Flag to track if the scheduler is active or not.
StatusCode isStalled(int si)
Check if the scheduling is in a stall.
std::string m_optimizationMode
virtual StatusCode popFinishedEvent(EventContext *&eventContext)
Blocks until an event is availble.
unsigned int m_maxAlgosInFlight
Maximum number of simultaneous algorithms.
AlgsExecutionStates::State State
The SchedulerSvc implements the IScheduler interface.
This class represents an entry point to all the event specific data.
SmartIF< IHiveWhiteBoard > m_whiteboard
A shortcut to the whiteboard.
StatusCode promoteToExecuted(unsigned int iAlgo, int si, IAlgorithm *algo)
The call to this method is triggered only from within the AlgoExecutionTask.
virtual StatusCode tryPopFinishedEvent(EventContext *&eventContext)
Try to fetch an event from the scheduler.
StatusCode m_drain()
Drain the actions present in the queue.
std::atomic_int m_freeSlots
Atomic to account for asyncronous updates by the scheduler wrt the rest.
~ForwardSchedulerSvc()
Destructor.
int m_threadPoolSize
Size of the threadpool initialised by TBB; a value of -1 gives TBB the freedom to choose...
unsigned int m_algosInFlight
Number of algoritms presently in flight.
Manage the execution flow using an execution flow graph Once initialized, the graph is const and can ...
tbb::concurrent_bounded_queue< EventContext * > m_finishedEvents
Queue of finished events.
std::thread m_thread
The thread in which the activate function runs.
std::vector< std::string > m_algname_vect
Vector to bookkeep the information necessary to the index2name conversion.
std::vector< EventSlot > m_eventSlots
Vector of events slots.
StatusCode promoteToScheduled(unsigned int iAlgo, int si)
StatusCode promoteToFinished(unsigned int iAlgo, int si)
This class is used for returning status codes from appropriate routines.
std::string m_whiteboardSvcName
The whiteboard name.
virtual StatusCode pushNewEvents(std::vector< EventContext * > &eventContexts)
unsigned int algname2index(const std::string &algoname)
Convert a name to an integer.
StatusCode updateStates(int si=-1, const std::string &algo_name=std::string())
Loop on algorithm in the slots and promote them to successive states (-1 means all slots...
std::unordered_map< std::string, unsigned int > m_algname_index_map
Map to bookkeep the information necessary to the name2index conversion.
The IAlgorithm is the interface implemented by the Algorithm base class.
virtual unsigned int freeSlots()
Get free slots number.
tbb::concurrent_bounded_queue< action > m_actionsQueue
Queue where closures are stored and picked for execution.
bool m_updateNeeded
Keep track of update actions scheduled.
std::function< StatusCode()> action
void activate()
Activate scheduler.
Base class used to extend a class implementing other interfaces.
int m_maxEventsInFlight
Maximum number of event processed simultaneously.
StatusCode promoteToControlReady(unsigned int iAlgo, int si)
Algorithm promotion: Accepted by the control flow.
concurrency::ExecutionFlowManager m_efManager
Member to take care of the control flow.
void dumpSchedulerState(int iSlot)
Dump the state of the scheduler.
bool m_dumpIntraEventDynamics
const std::string & index2algname(unsigned int index)
Convert an integer to a name.
virtual StatusCode finalize()
Finalise.
State
Execution states of the algorithms.
std::vector< std::vector< std::string > > m_algosDependencies
Ugly, will disappear when the deps are declared only within the C++ code of the algos.
StatusCode promoteToDataReady(unsigned int iAlgo, int si)