The Gaudi Framework  v30r2 (9eca68f7)
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 135 of file PRGraphVisitors.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 139 of file PRGraphVisitors.h.

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

Member Function Documentation

void concurrency::RunSimulator::reset ( )
inlineoverridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 152 of file PRGraphVisitors.h.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 543 of file PRGraphVisitors.cpp.

544  {
545 
546  bool allChildDecisionsResolved = true;
547 
548  for ( const auto& child : node.getDaughters() ) {
549 
550  child->accept( *this );
551 
552  int childDecision = m_slot->controlFlowState[child->getNodeIndex()];
553  if ( childDecision == -1 ) allChildDecisionsResolved = false;
554 
555  // process children sequentially if their decision hub is sequential
556  if ( !node.m_modeConcurrent && childDecision == -1 ) return false;
557 
558  if ( childDecision == 1 && node.m_modeOR && node.m_modePromptDecision ) {
559  m_slot->controlFlowState[node.getNodeIndex()] = 1;
560 
561  // if a decision was made for this node, propagate the result upwards
562  for ( auto parent : node.m_parents ) {
563  parent->accept( *this );
564  }
565  return true;
566  }
567  }
568 
569  if ( allChildDecisionsResolved ) {
570  m_slot->controlFlowState[node.getNodeIndex()] = 1;
571 
572  // if a decision was made for this node, propagate the result upwards
573  for ( auto parent : node.m_parents ) {
574  parent->accept( *this );
575  }
576  }
577 
578  return allChildDecisionsResolved;
579  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:54
bool concurrency::RunSimulator::visit ( AlgorithmNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 590 of file PRGraphVisitors.cpp.

591  {
592 
593  auto& states = m_slot->algsStates;
594  int& decision = m_slot->controlFlowState[node.getNodeIndex()];
595 
596  auto dataPromoter = DataReadyPromoter( *m_slot, m_cause );
597 
598  if ( State::INITIAL == states[node.getAlgoIndex()] ) {
599  states.updateState( node.getAlgoIndex(), State::CONTROLREADY );
600  if ( dataPromoter.visit( node ) ) {
601  states.updateState( node.getAlgoIndex(), State::SCHEDULED );
602  states.updateState( node.getAlgoIndex(), State::EVTACCEPTED );
603  decision = 1;
605  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
606  return true;
607  }
608  } else if ( State::CONTROLREADY == states[node.getAlgoIndex()] && dataPromoter.visit( node ) ) {
609  states.updateState( node.getAlgoIndex(), State::SCHEDULED );
610  states.updateState( node.getAlgoIndex(), State::EVTACCEPTED );
611  decision = 1;
613  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
614  return true;
615  }
616 
617  return false;
618  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:50
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:54
bool concurrency::RunSimulator::visitEnter ( DecisionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 535 of file PRGraphVisitors.cpp.

536  {
537 
538  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
539  return false;
540  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:54
bool concurrency::RunSimulator::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 582 of file PRGraphVisitors.cpp.

583  {
584 
585  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
586  return false;
587  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:54

Member Data Documentation

Cause concurrency::RunSimulator::m_cause

Definition at line 155 of file PRGraphVisitors.h.

int concurrency::RunSimulator::m_nodesSucceeded {0}

Definition at line 156 of file PRGraphVisitors.h.

EventSlot* concurrency::RunSimulator::m_slot

Definition at line 152 of file PRGraphVisitors.h.


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