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

#include <src/PRGraphVisitors.h>

Inheritance diagram for concurrency::Supervisor:
Collaboration diagram for concurrency::Supervisor:

Public Member Functions

 Supervisor (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 40 of file PRGraphVisitors.h.

Constructor & Destructor Documentation

concurrency::Supervisor::Supervisor ( EventSlot slot)
inline

Constructor.

Definition at line 43 of file PRGraphVisitors.h.

43  {
44  m_nodesSucceeded = 0;
45  m_slot = &slot;
46  };

Member Function Documentation

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 92 of file PRGraphVisitors.cpp.

92  {
93 
94  bool foundNonResolvedChild = false;
95  bool foundNegativeChild = false;
96  bool foundPositiveChild = false;
97  int decision = -1;
98 
99  for (auto child : node.getDaughters()) {
100  int& childDecision = m_slot->controlFlowState[child->getNodeIndex()];
101 
102  if (childDecision == -1)
103  foundNonResolvedChild = true;
104  else if (childDecision == 1)
105  foundPositiveChild = true;
106  else
107  foundNegativeChild = true;
108 
109  if (node.m_modePromptDecision) {
110  if (node.m_modeOR && foundPositiveChild) {
111  decision = 1;
112  break;
113  } else if (!node.m_modeOR && foundNegativeChild) {
114  decision = 0;
115  break;
116  }
117  } else {
118  if (foundNonResolvedChild)
119  break;
120  }
121  } // end monitoring children
122 
123  if (!foundNonResolvedChild && decision == -1) {
124  if (node.m_modeOR) { // OR
125  if (foundPositiveChild) decision = 1;
126  else decision = 0;
127  } else { // AND
128  if (foundNegativeChild) decision = 0;
129  else decision = 1;
130  }
131  }
132 
133  if (node.m_allPass && !foundNonResolvedChild)
134  decision = 1;
135 
136  if (decision != -1) {
137  m_slot->controlFlowState[node.getNodeIndex()] = decision;
138  return true;
139  }
140  return false;
141  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43
bool concurrency::Supervisor::visit ( AlgorithmNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 152 of file PRGraphVisitors.cpp.

152  {
153 
154  bool result = false;
155 
156  auto& states = m_slot->algsStates;
157  auto& state = states[node.getAlgoIndex()];
158 
159  // Promote with INITIAL->CR
160  if ( State::INITIAL == state )
161  states.updateState( node.getAlgoIndex(), State::CONTROLREADY ).ignore();
162 
163  // Try to promote with CR->DR
164  if ( State::CONTROLREADY == state ) {
165  auto promoter = DataReadyPromoter(*m_slot);
166  result = promoter.visit(node);
167  } else {
168  result = true;
169  }
170 
171  // return true only when an algorithm is not lower than DR in its FSM
172  // i.e., the visitor has done everything it could with this algorithm
173  return result;
174  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:37
bool concurrency::Supervisor::visitEnter ( DecisionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 84 of file PRGraphVisitors.cpp.

84  {
85 
86  if (m_slot->controlFlowState[node.getNodeIndex()] != -1)
87  return false;
88  return true;
89  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43
bool concurrency::Supervisor::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 144 of file PRGraphVisitors.cpp.

144  {
145 
146  if (m_slot->controlFlowState[node.getNodeIndex()] != -1)
147  return false;
148  return true;
149  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43

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