The Gaudi Framework  v33r0 (d5ea422b)
concurrency::RunSimulator Class Reference

#include <src/PRGraph/Visitors/Promoters.h>

Inheritance diagram for concurrency::RunSimulator:
Collaboration diagram for concurrency::RunSimulator:

Public Member Functions

 RunSimulator (EventSlot &slot, const Cause &cause)
 Constructor. More...
 
bool visitEnter (DecisionNode &) const override
 
bool visit (DecisionNode &) override
 
bool visitEnter (AlgorithmNode &) const override
 
bool visit (AlgorithmNode &) override
 
void reset () override
 
virtual bool visit (DecisionNode &)
 
virtual bool visit (AlgorithmNode &)
 
virtual bool visit (DataNode &)
 
virtual bool visit (ConditionNode &)
 
virtual bool visitEnter (DecisionNode &) const
 
virtual bool visitEnter (AlgorithmNode &) const
 
virtual bool visitEnter (DataNode &) const
 
virtual bool visitEnter (ConditionNode &) const
 
- Public Member Functions inherited from concurrency::IGraphVisitor
virtual ~IGraphVisitor ()=default
 
virtual bool visitEnter (DataNode &) const
 
virtual bool visit (DataNode &)
 
virtual bool visitEnter (ConditionNode &) const
 
virtual bool visit (ConditionNode &)
 

Public Attributes

EventSlotm_slot
 
Cause m_cause
 
int m_nodesSucceeded {0}
 

Detailed Description

Definition at line 87 of file Promoters.h.

Constructor & Destructor Documentation

◆ RunSimulator()

concurrency::RunSimulator::RunSimulator ( EventSlot slot,
const Cause cause 
)
inline

Constructor.

Definition at line 90 of file Promoters.h.

90 : m_slot( &slot ), m_cause( cause ){};

Member Function Documentation

◆ reset()

void concurrency::RunSimulator::reset ( )
inlineoverridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 103 of file Promoters.h.

◆ visit() [1/6]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 32 of file IGraphVisitor.h.

32 { return true; };

◆ visit() [2/6]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 35 of file IGraphVisitor.h.

35 { return true; };

◆ visit() [3/6]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 26 of file IGraphVisitor.h.

26 { return true; };

◆ visit() [4/6]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 29 of file IGraphVisitor.h.

29 { return true; };

◆ visit() [5/6]

bool concurrency::RunSimulator::visit ( DecisionNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 366 of file Promoters.cpp.

366  {
367 
368  bool allChildDecisionsResolved = true;
369 
370  for ( const auto& child : node.getDaughters() ) {
371 
372  child->accept( *this );
373 
374  int childDecision = m_slot->controlFlowState[child->getNodeIndex()];
375  if ( childDecision == -1 ) allChildDecisionsResolved = false;
376 
377  // process children sequentially if their decision hub is sequential
378  if ( !node.m_modeConcurrent && childDecision == -1 ) return false;
379 
380  if ( childDecision == 1 && node.m_modeOR && node.m_modePromptDecision ) {
381  m_slot->controlFlowState[node.getNodeIndex()] = 1;
382 
383  // if a decision was made for this node, propagate the result upwards
384  for ( auto parent : node.m_parents ) { parent->accept( *this ); }
385  return true;
386  }
387  }
388 
389  if ( allChildDecisionsResolved ) {
390  m_slot->controlFlowState[node.getNodeIndex()] = 1;
391 
392  // if a decision was made for this node, propagate the result upwards
393  for ( auto parent : node.m_parents ) { parent->accept( *this ); }
394  }
395 
396  return allChildDecisionsResolved;
397  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:87

◆ visit() [6/6]

bool concurrency::RunSimulator::visit ( AlgorithmNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 407 of file Promoters.cpp.

407  {
408 
409  auto& states = m_slot->algsStates;
410  int& decision = m_slot->controlFlowState[node.getNodeIndex()];
411 
412  auto dataPromoter = DataReadyPromoter( *m_slot, m_cause );
413 
414  if ( AState::INITIAL == states[node.getAlgoIndex()] ) {
415  states.set( node.getAlgoIndex(), AState::CONTROLREADY );
416  if ( dataPromoter.visit( node ) ) {
417  states.set( node.getAlgoIndex(), AState::SCHEDULED );
418  states.set( node.getAlgoIndex(), AState::EVTACCEPTED );
419  decision = 1;
421  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
422  return true;
423  }
424  } else if ( AState::CONTROLREADY == states[node.getAlgoIndex()] && dataPromoter.visit( node ) ) {
425  states.set( node.getAlgoIndex(), AState::SCHEDULED );
426  states.set( node.getAlgoIndex(), AState::EVTACCEPTED );
427  decision = 1;
429  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
430  return true;
431  }
432 
433  return false;
434  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:87
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:85

◆ visitEnter() [1/6]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 28 of file IGraphVisitor.h.

28 { return true; };

◆ visitEnter() [2/6]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 31 of file IGraphVisitor.h.

31 { return true; };

◆ visitEnter() [3/6]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 34 of file IGraphVisitor.h.

34 { return true; };

◆ visitEnter() [4/6]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 25 of file IGraphVisitor.h.

25 { return true; };

◆ visitEnter() [5/6]

bool concurrency::RunSimulator::visitEnter ( DecisionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 359 of file Promoters.cpp.

359  {
360 
361  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
362  return false;
363  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:87

◆ visitEnter() [6/6]

bool concurrency::RunSimulator::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 400 of file Promoters.cpp.

400  {
401 
402  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
403  return false;
404  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:87

Member Data Documentation

◆ m_cause

Cause concurrency::RunSimulator::m_cause

Definition at line 106 of file Promoters.h.

◆ m_nodesSucceeded

int concurrency::RunSimulator::m_nodesSucceeded {0}

Definition at line 107 of file Promoters.h.

◆ m_slot

EventSlot* concurrency::RunSimulator::m_slot

Definition at line 103 of file Promoters.h.


The documentation for this class was generated from the following files: