]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
Needed API modification before the concrete implementation. agy/ModeKeepGoingForEach
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 29 Jan 2015 08:04:50 +0000 (09:04 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 29 Jan 2015 08:04:50 +0000 (09:04 +0100)
13 files changed:
src/engine/Bloc.cxx
src/engine/Bloc.hxx
src/engine/ComposedNode.cxx
src/engine/ComposedNode.hxx
src/engine/DynParaLoop.cxx
src/engine/DynParaLoop.hxx
src/engine/Executor.cxx
src/engine/Executor.hxx
src/engine/ForEachLoop.cxx
src/engine/ForEachLoop.hxx
src/engine/OptimizerLoop.cxx
src/engine/OptimizerLoop.hxx
src/engine/Scheduler.hxx

index b12217dfb02b919e2637203f5cced5bc8e102a35..4c82d55db9822adc7530af349eebf73216b7237c 100644 (file)
@@ -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())
index 98f2e0fc0b6f9d6920fe16c4b105216d452a9c12..26b88c514265b7295a466126a545df1ce5e86116 100644 (file)
@@ -66,7 +66,7 @@ namespace YACS
       void checkNoCyclePassingThrough(Node *node) throw(Exception);
       std::vector< std::pair<OutGate *, InGate *> > 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;
index 5bf110794a9169267a6071c59b5e72697a5355ef..3f0e559d207130744025981e477ad1aff0fd94c5 100644 (file)
@@ -241,7 +241,8 @@ std::vector<Task *> 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;
index fcd0e13f16dd5026b51f376e03e61ab2f59c9a02..eb740c02d171e26d4482d7d80c01340826fc4de1 100644 (file)
@@ -64,7 +64,7 @@ namespace YACS
       DeploymentTree checkDeploymentTree(bool deep) const throw(Exception);
       std::vector<Task *> 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<ComposedNode *>& pointsOfViewStart,
                                         InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
       virtual void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView);
index 582ca5680706d18cd57f5bfc45e6a5596fd9d3ab..c63bdd04199c888219b54a779ecf5b411b013c4f 100644 (file)
@@ -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);
index 2ce21b66c89571d717c151fbcb2082a12cbd5a26..e7d5a2d24237ef7744ba6ce037896239b7432f22 100644 (file)
@@ -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<Node *> cloneAndPlaceNodesCoherently(const std::vector<Node *> & origNodes);
       Node * checkConsistencyAndSetNode(Node* &nodeToReplace, Node* DISOWNnode);
       Node * removeNode(Node* &nodeToRemove);
index ca8ca84bf89bf9322d278a3dfb05a3ccd590d9c9..4a86d63b1451fc10c01a3ec48f9cee21751424b8 100644 (file)
@@ -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<YACS::BASES::Mutex> 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<YACS::BASES::Mutex> 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<YACS::BASES::Mutex> 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<Task *>& tasks)
+void Executor::loadTasks(const std::vector<Task *>& tasks, const Executor *execInst)
 {
   for(std::vector<Task *>::const_iterator iter = _tasks.begin(); iter != _tasks.end(); iter++)
-    loadTask(*iter);
+    loadTask(*iter,execInst);
 }
 
-void Executor::loadParallelTasks(const std::vector<Task *>& tasks)
+void Executor::loadParallelTasks(const std::vector<Task *>& tasks, const Executor *execInst)
 {
   std::vector<Thread> ths(tasks.size());
   std::size_t ithread(0);
@@ -916,7 +916,7 @@ void Executor::launchTasks(const std::vector<Task *>& tasks)
           {//Critical section
             YACS::BASES::AutoLocker<YACS::BASES::Mutex> 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<Task *>& tasks)
           {//Critical section
             YACS::BASES::AutoLocker<YACS::BASES::Mutex> 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<Task *>& tasks)
               {//Critical section
                 YACS::BASES::AutoLocker<YACS::BASES::Mutex> 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)
       {
index fedd17196307f5b1f778fe0827bdb15af75e4674..b76a213857c5eb5140799468250868ae8f18005f 100644 (file)
@@ -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<Task *>& tasks);
-      void loadParallelTasks(const std::vector<Task *>& tasks);
+      void loadTask(Task *task, const Executor *execInst);
+      void loadTasks(const std::vector<Task *>& tasks, const Executor *execInst);
+      void loadParallelTasks(const std::vector<Task *>& tasks, const Executor *execInst);
       void launchTasks(const std::vector<Task*>& tasks);
       void launchTask(Task *task);
       void wakeUp();
index 325d05801544b40168e23fa026d23eef62b16c53..e2fe9ab654306aa0cff3b26b8916b828fda6ba63 100644 (file)
@@ -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<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
 {
   DynParaLoop::buildDelegateOf(port,finalTarget,pointsOfView);
index f390dcd363a312a2a76322e1a23b070bb7eab479..abe3e35e07950fe610e76626377177fb2a2a750c 100644 (file)
@@ -179,6 +179,7 @@ namespace YACS
       void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
                                 InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
       YACS::Event updateStateOnFinishedEventFrom(Node *node);
+      YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
       void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
       void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
       void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
index b3c0c0010e9554b8aa07ec0b66bcb5079b9d6cec..ce8782328a951069235dc0ace10d89d4d89a8df7 100644 (file)
@@ -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)
index 88c8d30e9e6ae79958d90cd4a1a499ccd32ae08f..2a2fbe29320b8b1387cd8e1788f4e967070c3835 100644 (file)
@@ -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<ComposedNode *>& pointsOfView);
       void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
       void checkControlDependancy(OutPort *start, InPort *end, bool cross,
index 020f90dcc394b703ed65542c3ead1e83b1213190..abc6070b93620a0818cdf34f00c5ff101a45c765 100644 (file)
@@ -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<Task *> getNextTasks(bool& isMore) = 0;
       virtual void selectRunnableTasks(std::vector<Task *>& 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;