1 #ifndef __EXECUTOR_HXX__
2 #define __EXECUTOR_HXX__
6 #include "Semaphore.hxx"
7 #include "Exception.hxx"
23 /*! \brief Threaded Executor
32 Scheduler *_mainSched;
34 int _nbOfConcurrentThreads;
35 YACS::BASES::Mutex _mutexForNbOfConcurrentThreads;
36 YACS::BASES::Condition _condForNewTasksToPerform;
37 YACS::BASES::Semaphore _semForMaxThreads;
38 YACS::BASES::Condition _condForStepByStep;
39 YACS::BASES::Condition _condForPilot;
40 YACS::BASES::Mutex _mutexForSchedulerUpdate;
41 YACS::BASES::Mutex _mutexForTrace;
44 bool _stopOnErrorRequested;
45 bool _dumpOnErrorRequested;
47 bool _isRunningunderExternalControl;
48 bool _isWaitingEventsFromRunningTasks;
49 int _numberOfRunningTasks;
51 YACS::ExecutorState _executorState;
52 YACS::ExecutionMode _execMode;
53 std::list<std::string> _listOfBreakPoints;
54 std::list<std::string> _listOfTasksToLoad;
55 std::vector<Task *> _tasks;
56 std::vector<Task *> _tasksSave;
57 std::list< YACS::BASES::Thread * > _groupOfAllThreadsCreated;
59 std::string _dumpErrorFile;
63 void RunA(Scheduler *graph,int debug=0, bool fromScratch=true);
64 void RunW(Scheduler *graph,int debug=0, bool fromScratch=true) { RunB(graph, debug, fromScratch); }
65 void RunB(Scheduler *graph,int debug=0, bool fromScratch=true);
66 YACS::ExecutionMode getCurrentExecMode();
67 YACS::ExecutorState getExecutorState();
68 void setExecMode(YACS::ExecutionMode mode);
69 void setListOfBreakPoints(std::list<std::string> listOfBreakPoints);
70 std::list<std::string> getTasksToLoad();
71 bool setStepsToExecute(std::list<std::string> listToExecute);
72 bool resumeCurrentBreakPoint();
75 bool saveState(const std::string& xmlFile);
78 void displayDot(Scheduler *graph);
79 void setStopOnError(bool dumpRequested=false, std::string xmlFile="");
82 bool checkBreakPoints();
84 void loadTask(Task *task);
85 void launchTasks(std::vector<Task*>& tasks);
86 void launchTask(Task *task);
88 void sleepWhileNoEventsFromAnyRunningTask();
89 void notifyEndOfThread(YACS::BASES::Thread *thread);
90 void traceExec(Task *task, const std::string& message);
91 void _displayDot(Scheduler *graph);
92 virtual void sendEvent(const std::string& event);
94 static void *functionForTaskExecution(void *);