The Gaudi Framework  v28r3 (cc1cf868)
concurrency::RunSimulator Class Reference

#include <src/PRGraphVisitors.h>

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

Public Member Functions

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

Additional Inherited Members

- Public Attributes inherited from concurrency::IGraphVisitor
int m_nodesSucceeded
 
EventSlotm_slot
 

Detailed Description

Definition at line 144 of file PRGraphVisitors.h.

Constructor & Destructor Documentation

concurrency::RunSimulator::RunSimulator ( EventSlot slot)
inline

Constructor.

Definition at line 147 of file PRGraphVisitors.h.

147  {
148  m_nodesSucceeded = 0;
149  m_slot = &slot;
150  };

Member Function Documentation

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 351 of file PRGraphVisitors.cpp.

351  {
352 
353  //std::cout << "1-st level Decision: " << node.getNodeName() << std::endl;
354  bool allChildDecisionsResolved = true;
355  for (auto child : node.getDaughters()) {
356  int& childDecision = m_slot->controlFlowState[child->getNodeIndex()];
357 
358  if (childDecision == 1 && node.m_modeOR && node.m_modePromptDecision) {
359  m_slot->controlFlowState[node.getNodeIndex()] = 1;
360  return true;
361  }
362 
363  if (childDecision == -1) {
364  allChildDecisionsResolved = false;
365  }
366  }
367 
368  if (allChildDecisionsResolved)
369  m_slot->controlFlowState[node.getNodeIndex()] = 1;
370 
371  return allChildDecisionsResolved;
372  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43
bool concurrency::RunSimulator::visit ( AlgorithmNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 383 of file PRGraphVisitors.cpp.

383  {
384 
385  auto& states = m_slot->algsStates;
386  int& decision = m_slot->controlFlowState[node.getNodeIndex()];
387 
388  auto dataPromoter = DataReadyPromoter(*m_slot);
389 
390  if (State::INITIAL == states[node.getAlgoIndex()]) {
391  states.updateState(node.getAlgoIndex(), State::CONTROLREADY);
392  if (dataPromoter.visit(node)) {
393  states.updateState(node.getAlgoIndex(), State::SCHEDULED);
394  states.updateState(node.getAlgoIndex(), State::EVTACCEPTED);
395  decision = 1;
397  //std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
398  return true;
399  }
400  } else if (State::CONTROLREADY == states[node.getAlgoIndex()] && dataPromoter.visit(node)) {
401  states.updateState(node.getAlgoIndex(), State::SCHEDULED);
402  states.updateState(node.getAlgoIndex(), State::EVTACCEPTED);
403  decision = 1;
405  //std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
406  return true;
407  }
408 
409  return false;
410  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:37
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43
bool concurrency::RunSimulator::visitEnter ( DecisionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 343 of file PRGraphVisitors.cpp.

343  {
344 
345  if (m_slot->controlFlowState[node.getNodeIndex()] != 1)
346  return true;
347  return false;
348  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43
bool concurrency::RunSimulator::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 375 of file PRGraphVisitors.cpp.

375  {
376 
377  if (m_slot->controlFlowState[node.getNodeIndex()] != 1)
378  return true;
379  return false;
380  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43

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