From: Anthony Geay Date: Thu, 29 Jan 2015 08:04:50 +0000 (+0100) Subject: Needed API modification before the concrete implementation. X-Git-Tag: V7_6_0a1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fagy%2FModeKeepGoingForEach;p=modules%2Fyacs.git Needed API modification before the concrete implementation. --- diff --git a/src/engine/Bloc.cxx b/src/engine/Bloc.cxx index b12217dfb..4c82d55db 100644 --- a/src/engine/Bloc.cxx +++ b/src/engine/Bloc.cxx @@ -349,7 +349,7 @@ YACS::Event Bloc::updateStateOnFinishedEventFrom(Node *node) * \param node : node that has emitted the event * \return the event to notify to bloc's father */ -YACS::Event Bloc::updateStateOnFailedEventFrom(Node *node) +YACS::Event Bloc::updateStateOnFailedEventFrom(Node *node, const Executor *execInst) { node->exForwardFailed(); if(areAllSubNodesFinished()) diff --git a/src/engine/Bloc.hxx b/src/engine/Bloc.hxx index 98f2e0fc0..26b88c514 100644 --- a/src/engine/Bloc.hxx +++ b/src/engine/Bloc.hxx @@ -66,7 +66,7 @@ namespace YACS void checkNoCyclePassingThrough(Node *node) throw(Exception); std::vector< std::pair > getSetOfInternalCFLinks() const; YACS::Event updateStateOnFinishedEventFrom(Node *node); - YACS::Event updateStateOnFailedEventFrom(Node *node); + YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst); void initComputation() const; void performCFComputations(LinkInfo& info) const; void destructCFComputations(LinkInfo& info) const; diff --git a/src/engine/ComposedNode.cxx b/src/engine/ComposedNode.cxx index 5bf110794..3f0e559d2 100644 --- a/src/engine/ComposedNode.cxx +++ b/src/engine/ComposedNode.cxx @@ -241,7 +241,8 @@ std::vector ComposedNode::getNextTasks(bool& isMore) * Calls ComposedNode::updateStateFrom to update state from task to root node */ void ComposedNode::notifyFrom(const Task *sender, //* I : task emitting event - YACS::Event event //* I : event emitted + YACS::Event event, //* I : event emitted + const Executor *execInst ) { DEBTRACE("ComposedNode::notifyFrom " << event); @@ -251,12 +252,12 @@ void ComposedNode::notifyFrom(const Task *sender, //* I : task emitting event ComposedNode *curLevelNode=taskTyped->_father; if(!curLevelNode)//Specific case of loop when 0 turn is specified without any enclosing bloc. return ; - curEvent=curLevelNode->updateStateFrom(lminus1LevelNode,curEvent); + curEvent=curLevelNode->updateStateFrom(lminus1LevelNode,curEvent,execInst); while(curEvent!=YACS::NOEVENT && curLevelNode!=this) { lminus1LevelNode=curLevelNode; curLevelNode=curLevelNode->_father; - curEvent=curLevelNode->updateStateFrom(lminus1LevelNode,curEvent); + curEvent=curLevelNode->updateStateFrom(lminus1LevelNode,curEvent,execInst); } } @@ -1318,7 +1319,8 @@ OutputDataStreamPort *ComposedNode::getOutputDataStreamPort(const std::string& n * Called by ComposedNode::notifyFrom */ YACS::Event ComposedNode::updateStateFrom(Node *node, //* I : node emitting event - YACS::Event event //* I : event emitted + YACS::Event event, //* I : event emitted + const Executor *execInst ) { DEBTRACE("updateStateFrom: " << node->getName() << " " << event); @@ -1333,7 +1335,7 @@ YACS::Event ComposedNode::updateStateFrom(Node *node, //* I : node emitti return updateStateOnFinishedEventFrom(node); break; case YACS::ABORT: - return updateStateOnFailedEventFrom(node); + return updateStateOnFailedEventFrom(node,execInst); break; default: return YACS::NOEVENT;//TODO unexpected type of event @@ -1375,7 +1377,7 @@ YACS::Event ComposedNode::updateStateOnStartEventFrom(Node *node) } //! Method used to notify the node that a child node has failed -YACS::Event ComposedNode::updateStateOnFailedEventFrom(Node *node) +YACS::Event ComposedNode::updateStateOnFailedEventFrom(Node *node, const Executor *execInst) { setState(YACS::FAILED); return YACS::ABORT; diff --git a/src/engine/ComposedNode.hxx b/src/engine/ComposedNode.hxx index fcd0e13f1..eb740c02d 100644 --- a/src/engine/ComposedNode.hxx +++ b/src/engine/ComposedNode.hxx @@ -64,7 +64,7 @@ namespace YACS DeploymentTree checkDeploymentTree(bool deep) const throw(Exception); std::vector getNextTasks(bool& isMore); virtual bool isPlacementPredictableB4Run() const = 0; - void notifyFrom(const Task *sender, YACS::Event event); + void notifyFrom(const Task *sender, YACS::Event event, const Executor *execInst); bool edAddLink(OutPort *start, InPort *end) throw(Exception); virtual bool edAddDFLink(OutPort *start, InPort *end) throw(Exception); //Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++ @@ -133,10 +133,10 @@ namespace YACS static bool splitNamesBySep(const std::string& globalName, const char separator[], std::string& firstPart, std::string& lastPart, bool priority) throw(Exception); virtual Node *getChildByShortName(const std::string& name) const throw(Exception) = 0; - YACS::Event updateStateFrom(Node *node, YACS::Event event);//update the state of this. Precondition : node->_father == this + YACS::Event updateStateFrom(Node *node, YACS::Event event, const Executor *execInst);//update the state of this. Precondition : node->_father == this virtual YACS::Event updateStateOnStartEventFrom(Node *node);//transition 3 doc P.R virtual YACS::Event updateStateOnFinishedEventFrom(Node *node) = 0;//transition 9 doc P.R. - virtual YACS::Event updateStateOnFailedEventFrom(Node *node);//transition 9 doc P.R. + virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);//transition 9 doc P.R. virtual void checkLinkPossibility(OutPort *start, const std::list& pointsOfViewStart, InPort *end, const std::list& pointsOfViewEnd) throw(Exception); virtual void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list& pointsOfView); diff --git a/src/engine/DynParaLoop.cxx b/src/engine/DynParaLoop.cxx index 582ca5680..c63bdd041 100644 --- a/src/engine/DynParaLoop.cxx +++ b/src/engine/DynParaLoop.cxx @@ -629,7 +629,7 @@ void DynParaLoop::forwardExecStateToOriginalBody(Node *execNode) * \param node : the child node that has failed * \return the state change */ -YACS::Event DynParaLoop::updateStateOnFailedEventFrom(Node *node) +YACS::Event DynParaLoop::updateStateOnFailedEventFrom(Node *node, const Executor *execInst) { DEBTRACE("DynParaLoop::updateStateOnFailedEventFrom " << node->getName()); setState(YACS::FAILED); diff --git a/src/engine/DynParaLoop.hxx b/src/engine/DynParaLoop.hxx index 2ce21b66c..e7d5a2d24 100644 --- a/src/engine/DynParaLoop.hxx +++ b/src/engine/DynParaLoop.hxx @@ -119,7 +119,7 @@ namespace YACS TypeOfNode getIdentityOfNotifyerNode(const Node *node, unsigned& id); InputPort *getDynInputPortByAbsName(int branchNb, const std::string& name, bool initNodeAdmitted); virtual void forwardExecStateToOriginalBody(Node *execNode); - virtual YACS::Event updateStateOnFailedEventFrom(Node *node); + virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst); std::vector cloneAndPlaceNodesCoherently(const std::vector & origNodes); Node * checkConsistencyAndSetNode(Node* &nodeToReplace, Node* DISOWNnode); Node * removeNode(Node* &nodeToRemove); diff --git a/src/engine/Executor.cxx b/src/engine/Executor.cxx index ca8ca84bf..4a86d63b1 100644 --- a/src/engine/Executor.cxx +++ b/src/engine/Executor.cxx @@ -75,7 +75,7 @@ using YACS::BASES::Semaphore; int Executor::_maxThreads(50); size_t Executor::_threadStackSize(1048576); // Default thread stack size is 1MB -Executor::Executor():_nbOfConcurrentThreads(0), _semForMaxThreads(_maxThreads) +Executor::Executor():_nbOfConcurrentThreads(0), _semForMaxThreads(_maxThreads),_keepGoingOnFail(false) { _root=0; _toContinue = true; @@ -147,7 +147,7 @@ void Executor::RunA(Scheduler *graph,int debug, bool fromScratch) if(debug>2)_displayDot(graph); for(iter=tasks.begin();iter!=tasks.end();iter++) - loadTask(*iter); + loadTask(*iter,this); if(debug>1)_displayDot(graph); @@ -306,7 +306,7 @@ void Executor::RunB(Scheduler *graph,int debug, bool fromScratch) if (debug > 0) _displayDot(graph); DEBTRACE("---"); //loadTasks(_tasks); - loadParallelTasks(_tasks); + loadParallelTasks(_tasks,this); if (debug > 1) _displayDot(graph); DEBTRACE("---"); launchTasks(_tasks); @@ -810,7 +810,7 @@ void Executor::waitResume() * \param task : Task to load */ -void Executor::loadTask(Task *task) +void Executor::loadTask(Task *task, const Executor *execInst) { DEBTRACE("Executor::loadTask(Task *task)"); if(task->getState() != YACS::TOLOAD) @@ -818,7 +818,7 @@ void Executor::loadTask(Task *task) traceExec(task, "state:TOLOAD", ComputePlacement(task)); {//Critical section YACS::BASES::AutoLocker alck(&_mutexForSchedulerUpdate); - _mainSched->notifyFrom(task,YACS::START); + _mainSched->notifyFrom(task,YACS::START,execInst); }//End of critical section try { @@ -833,7 +833,7 @@ void Executor::loadTask(Task *task) {//Critical section YACS::BASES::AutoLocker alck(&_mutexForSchedulerUpdate); task->aborted(); - _mainSched->notifyFrom(task,YACS::ABORT); + _mainSched->notifyFrom(task,YACS::ABORT,execInst); traceExec(task, "state:"+Node::getStateName(task->getState()), ComputePlacement(task)); }//End of critical section } @@ -843,7 +843,7 @@ void Executor::loadTask(Task *task) {//Critical section YACS::BASES::AutoLocker alck(&_mutexForSchedulerUpdate); task->aborted(); - _mainSched->notifyFrom(task,YACS::ABORT); + _mainSched->notifyFrom(task,YACS::ABORT,execInst); traceExec(task, "state:"+Node::getStateName(task->getState()), ComputePlacement(task)); }//End of critical section } @@ -856,13 +856,13 @@ struct threadargs Executor *execInst; }; -void Executor::loadTasks(const std::vector& tasks) +void Executor::loadTasks(const std::vector& tasks, const Executor *execInst) { for(std::vector::const_iterator iter = _tasks.begin(); iter != _tasks.end(); iter++) - loadTask(*iter); + loadTask(*iter,execInst); } -void Executor::loadParallelTasks(const std::vector& tasks) +void Executor::loadParallelTasks(const std::vector& tasks, const Executor *execInst) { std::vector ths(tasks.size()); std::size_t ithread(0); @@ -916,7 +916,7 @@ void Executor::launchTasks(const std::vector& tasks) {//Critical section YACS::BASES::AutoLocker alck(&_mutexForSchedulerUpdate); (*iter)->aborted(); - _mainSched->notifyFrom(*iter,YACS::ABORT); + _mainSched->notifyFrom(*iter,YACS::ABORT,this); }//End of critical section } catch(...) @@ -935,7 +935,7 @@ void Executor::launchTasks(const std::vector& tasks) {//Critical section YACS::BASES::AutoLocker alck(&_mutexForSchedulerUpdate); (*iter)->aborted(); - _mainSched->notifyFrom(*iter,YACS::ABORT); + _mainSched->notifyFrom(*iter,YACS::ABORT,this); }//End of critical section } if((*iter)->getState() == YACS::ERROR) @@ -961,7 +961,7 @@ void Executor::launchTasks(const std::vector& tasks) {//Critical section YACS::BASES::AutoLocker alck(&_mutexForSchedulerUpdate); t->aborted(); - _mainSched->notifyFrom(t,YACS::ABORT); + _mainSched->notifyFrom(t,YACS::ABORT,this); }//End of critical section traceExec(t, "state:"+Node::getStateName(t->getState()),ComputePlacement(*iter)); } @@ -1103,7 +1103,7 @@ void *Executor::functionForTaskLoad(void *arg) Scheduler *sched=args->sched; Executor *execInst=args->execInst; delete args; - execInst->loadTask(task);// no throw of this method - all throw are catched ! + execInst->loadTask(task,execInst);// no throw of this method - all throw are catched ! return 0; } @@ -1203,7 +1203,7 @@ void *Executor::functionForTaskExecution(void *arg) task->aborted(); } execInst->traceExec(task, "state:"+Node::getStateName(task->getState()),placement); - sched->notifyFrom(task,ev); + sched->notifyFrom(task,ev,execInst); } catch(Exception& ex) { diff --git a/src/engine/Executor.hxx b/src/engine/Executor.hxx index fedd17196..b76a21385 100644 --- a/src/engine/Executor.hxx +++ b/src/engine/Executor.hxx @@ -85,6 +85,7 @@ namespace YACS std::list< YACS::BASES::Thread * > _groupOfAllThreadsCreated; std::ofstream _trace; std::string _dumpErrorFile; + bool _keepGoingOnFail; #ifdef WIN32 DWORD _start; #else @@ -96,6 +97,8 @@ namespace YACS void RunA(Scheduler *graph,int debug=0, bool fromScratch=true); void RunW(Scheduler *graph,int debug=0, bool fromScratch=true) { RunB(graph, debug, fromScratch); } void RunB(Scheduler *graph,int debug=0, bool fromScratch=true); + void setKeepGoingProperty(bool newVal) { _keepGoingOnFail=newVal; } + bool getKeepGoingProperty() const { return _keepGoingOnFail; } YACS::ExecutionMode getCurrentExecMode(); YACS::ExecutorState getExecutorState(); void setExecMode(YACS::ExecutionMode mode); @@ -118,9 +121,9 @@ namespace YACS protected: bool checkBreakPoints(); void waitResume(); - void loadTask(Task *task); - void loadTasks(const std::vector& tasks); - void loadParallelTasks(const std::vector& tasks); + void loadTask(Task *task, const Executor *execInst); + void loadTasks(const std::vector& tasks, const Executor *execInst); + void loadParallelTasks(const std::vector& tasks, const Executor *execInst); void launchTasks(const std::vector& tasks); void launchTask(Task *task); void wakeUp(); diff --git a/src/engine/ForEachLoop.cxx b/src/engine/ForEachLoop.cxx index 325d05801..e2fe9ab65 100644 --- a/src/engine/ForEachLoop.cxx +++ b/src/engine/ForEachLoop.cxx @@ -650,6 +650,11 @@ YACS::Event ForEachLoop::updateStateOnFinishedEventFrom(Node *node) return YACS::NOEVENT; } +YACS::Event ForEachLoop::updateStateOnFailedEventFrom(Node *node, const Executor *execInst) +{ + return DynParaLoop::updateStateOnFailedEventFrom(node,execInst); +} + void ForEachLoop::buildDelegateOf(std::pair& port, InPort *finalTarget, const std::list& pointsOfView) { DynParaLoop::buildDelegateOf(port,finalTarget,pointsOfView); diff --git a/src/engine/ForEachLoop.hxx b/src/engine/ForEachLoop.hxx index f390dcd36..abe3e35e0 100644 --- a/src/engine/ForEachLoop.hxx +++ b/src/engine/ForEachLoop.hxx @@ -179,6 +179,7 @@ namespace YACS void checkLinkPossibility(OutPort *start, const std::list& pointsOfViewStart, InPort *end, const std::list& pointsOfViewEnd) throw(Exception); YACS::Event updateStateOnFinishedEventFrom(Node *node); + YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst); void buildDelegateOf(std::pair& port, InPort *finalTarget, const std::list& pointsOfView); void getDelegateOf(std::pair& port, InPort *finalTarget, const std::list& pointsOfView) throw(Exception); void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list& pointsOfView) throw(Exception); diff --git a/src/engine/OptimizerLoop.cxx b/src/engine/OptimizerLoop.cxx index b3c0c0010..ce8782328 100644 --- a/src/engine/OptimizerLoop.cxx +++ b/src/engine/OptimizerLoop.cxx @@ -444,7 +444,7 @@ YACS::Event OptimizerLoop::finalize() * \param node : the child node that has failed * \return the state change */ -YACS::Event OptimizerLoop::updateStateOnFailedEventFrom(Node *node) +YACS::Event OptimizerLoop::updateStateOnFailedEventFrom(Node *node, const Executor *execInst) { DEBTRACE("OptimizerLoop::updateStateOnFailedEventFrom " << node->getName()); _alg->setError(string("Error during the execution of YACS node ") + node->getName() + @@ -452,7 +452,7 @@ YACS::Event OptimizerLoop::updateStateOnFailedEventFrom(Node *node) _alg->finishProxy(); _myPool.destroyAll(); DEBTRACE("OptimizerLoop::updateStateOnFailedEventFrom: returned from error notification."); - return DynParaLoop::updateStateOnFailedEventFrom(node); + return DynParaLoop::updateStateOnFailedEventFrom(node,execInst); } void OptimizerLoop::checkNoCyclePassingThrough(Node *node) throw(YACS::Exception) diff --git a/src/engine/OptimizerLoop.hxx b/src/engine/OptimizerLoop.hxx index 88c8d30e9..2a2fbe293 100644 --- a/src/engine/OptimizerLoop.hxx +++ b/src/engine/OptimizerLoop.hxx @@ -107,7 +107,7 @@ namespace YACS YACS::Event finalize(); protected: - virtual YACS::Event updateStateOnFailedEventFrom(Node *node); + virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst); void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list& pointsOfView); void buildDelegateOf(std::pair& port, InPort *finalTarget, const std::list& pointsOfView); void checkControlDependancy(OutPort *start, InPort *end, bool cross, diff --git a/src/engine/Scheduler.hxx b/src/engine/Scheduler.hxx index 020f90dcc..abc6070b9 100644 --- a/src/engine/Scheduler.hxx +++ b/src/engine/Scheduler.hxx @@ -31,6 +31,7 @@ namespace YACS namespace ENGINE { class Task; + class Executor; class Scheduler { @@ -42,7 +43,7 @@ namespace YACS virtual std::string getTaskName(Task *task) const = 0; virtual std::vector getNextTasks(bool& isMore) = 0; virtual void selectRunnableTasks(std::vector& tasks) = 0; - virtual void notifyFrom(const Task *sender, YACS::Event event) = 0; + virtual void notifyFrom(const Task *sender, YACS::Event event, const Executor *execInst) = 0; //Placement methods virtual DeploymentTree getDeploymentTree() const = 0; virtual bool isPlacementPredictableB4Run() const = 0;