The Gaudi Framework  v31r0 (aeb156f0)
concurrency::RunSimulator Class Reference

#include <src/PRGraphVisitors.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
 
- 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 125 of file PRGraphVisitors.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 128 of file PRGraphVisitors.h.

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

Member Function Documentation

void concurrency::RunSimulator::reset ( )
inlineoverridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 141 of file PRGraphVisitors.h.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 513 of file PRGraphVisitors.cpp.

513  {
514 
515  bool allChildDecisionsResolved = true;
516 
517  for ( const auto& child : node.getDaughters() ) {
518 
519  child->accept( *this );
520 
521  int childDecision = m_slot->controlFlowState[child->getNodeIndex()];
522  if ( childDecision == -1 ) allChildDecisionsResolved = false;
523 
524  // process children sequentially if their decision hub is sequential
525  if ( !node.m_modeConcurrent && childDecision == -1 ) return false;
526 
527  if ( childDecision == 1 && node.m_modeOR && node.m_modePromptDecision ) {
528  m_slot->controlFlowState[node.getNodeIndex()] = 1;
529 
530  // if a decision was made for this node, propagate the result upwards
531  for ( auto parent : node.m_parents ) { parent->accept( *this ); }
532  return true;
533  }
534  }
535 
536  if ( allChildDecisionsResolved ) {
537  m_slot->controlFlowState[node.getNodeIndex()] = 1;
538 
539  // if a decision was made for this node, propagate the result upwards
540  for ( auto parent : node.m_parents ) { parent->accept( *this ); }
541  }
542 
543  return allChildDecisionsResolved;
544  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:77
bool concurrency::RunSimulator::visit ( AlgorithmNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 554 of file PRGraphVisitors.cpp.

554  {
555 
556  auto& states = m_slot->algsStates;
557  int& decision = m_slot->controlFlowState[node.getNodeIndex()];
558 
559  auto dataPromoter = DataReadyPromoter( *m_slot, m_cause );
560 
561  if ( AState::INITIAL == states[node.getAlgoIndex()] ) {
562  states.set( node.getAlgoIndex(), AState::CONTROLREADY );
563  if ( dataPromoter.visit( node ) ) {
564  states.set( node.getAlgoIndex(), AState::SCHEDULED );
565  states.set( node.getAlgoIndex(), AState::EVTACCEPTED );
566  decision = 1;
568  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
569  return true;
570  }
571  } else if ( AState::CONTROLREADY == states[node.getAlgoIndex()] && dataPromoter.visit( node ) ) {
572  states.set( node.getAlgoIndex(), AState::SCHEDULED );
573  states.set( node.getAlgoIndex(), AState::EVTACCEPTED );
574  decision = 1;
576  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
577  return true;
578  }
579 
580  return false;
581  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:77
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:75
bool concurrency::RunSimulator::visitEnter ( DecisionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 506 of file PRGraphVisitors.cpp.

506  {
507 
508  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
509  return false;
510  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:77
bool concurrency::RunSimulator::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 547 of file PRGraphVisitors.cpp.

547  {
548 
549  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
550  return false;
551  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:77

Member Data Documentation

Cause concurrency::RunSimulator::m_cause

Definition at line 144 of file PRGraphVisitors.h.

int concurrency::RunSimulator::m_nodesSucceeded {0}

Definition at line 145 of file PRGraphVisitors.h.

EventSlot* concurrency::RunSimulator::m_slot

Definition at line 141 of file PRGraphVisitors.h.


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