The Gaudi Framework  v30r3 (a5ef0a68)
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 537 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 584 of file PRGraphVisitors.cpp.

585  {
586 
587  auto& states = m_slot->algsStates;
588  int& decision = m_slot->controlFlowState[node.getNodeIndex()];
589 
590  auto dataPromoter = DataReadyPromoter( *m_slot, m_cause );
591 
592  if ( AState::INITIAL == states[node.getAlgoIndex()] ) {
593  states.set( node.getAlgoIndex(), AState::CONTROLREADY );
594  if ( dataPromoter.visit( node ) ) {
595  states.set( node.getAlgoIndex(), AState::SCHEDULED );
596  states.set( node.getAlgoIndex(), AState::EVTACCEPTED );
597  decision = 1;
599  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
600  return true;
601  }
602  } else if ( AState::CONTROLREADY == states[node.getAlgoIndex()] && dataPromoter.visit( node ) ) {
603  states.set( node.getAlgoIndex(), AState::SCHEDULED );
604  states.set( node.getAlgoIndex(), AState::EVTACCEPTED );
605  decision = 1;
607  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
608  return true;
609  }
610 
611  return false;
612  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:49
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:53
bool concurrency::RunSimulator::visitEnter ( DecisionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 529 of file PRGraphVisitors.cpp.

530  {
531 
532  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
533  return false;
534  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:53
bool concurrency::RunSimulator::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 576 of file PRGraphVisitors.cpp.

577  {
578 
579  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
580  return false;
581  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:53

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: