* \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())
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;
* 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);
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);
}
}
* 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);
return updateStateOnFinishedEventFrom(node);
break;
case YACS::ABORT:
- return updateStateOnFailedEventFrom(node);
+ return updateStateOnFailedEventFrom(node,execInst);
break;
default:
return YACS::NOEVENT;//TODO unexpected type of event
}
//! 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;
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++
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);
* \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);
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);
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;
if(debug>2)_displayDot(graph);
for(iter=tasks.begin();iter!=tasks.end();iter++)
- loadTask(*iter);
+ loadTask(*iter,this);
if(debug>1)_displayDot(graph);
if (debug > 0) _displayDot(graph);
DEBTRACE("---");
//loadTasks(_tasks);
- loadParallelTasks(_tasks);
+ loadParallelTasks(_tasks,this);
if (debug > 1) _displayDot(graph);
DEBTRACE("---");
launchTasks(_tasks);
* \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)
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
{
{//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
}
{//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
}
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);
{//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(...)
{//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)
{//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));
}
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;
}
task->aborted();
}
execInst->traceExec(task, "state:"+Node::getStateName(task->getState()),placement);
- sched->notifyFrom(task,ev);
+ sched->notifyFrom(task,ev,execInst);
}
catch(Exception& ex)
{
std::list< YACS::BASES::Thread * > _groupOfAllThreadsCreated;
std::ofstream _trace;
std::string _dumpErrorFile;
+ bool _keepGoingOnFail;
#ifdef WIN32
DWORD _start;
#else
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);
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();
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);
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);
* \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() +
_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)
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,
namespace ENGINE
{
class Task;
+ class Executor;
class Scheduler
{
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;