The Gaudi Framework  v29r0 (ff2e7097)
concurrency::Supervisor Class Reference

#include <src/PRGraphVisitors.h>

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

Public Member Functions

 Supervisor (EventSlot &slot, const Cause &cause, bool ifTrace=false)
 Constructor. More...
 
bool visitEnter (DecisionNode &) const override
 
bool visit (DecisionNode &) override
 
bool visitEnter (AlgorithmNode &) const override
 
bool visit (AlgorithmNode &) 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 &)
 
virtual void reset ()
 

Public Attributes

EventSlotm_slot
 
Cause m_cause
 
bool m_trace
 

Detailed Description

Definition at line 54 of file PRGraphVisitors.h.

Constructor & Destructor Documentation

concurrency::Supervisor::Supervisor ( EventSlot slot,
const Cause cause,
bool  ifTrace = false 
)
inline

Constructor.

Definition at line 58 of file PRGraphVisitors.h.

59  : m_slot( &slot ), m_cause( cause ), m_trace( ifTrace ){};

Member Function Documentation

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 140 of file PRGraphVisitors.cpp.

141  {
142 
143  bool foundNonResolvedChild = false;
144  bool foundNegativeChild = false;
145  bool foundPositiveChild = false;
146  int decision = -1;
147 
148  for ( auto child : node.getDaughters() ) {
149  int& childDecision = m_slot->controlFlowState[child->getNodeIndex()];
150 
151  if ( childDecision == -1 )
152  foundNonResolvedChild = true;
153  else if ( childDecision == 1 )
154  foundPositiveChild = true;
155  else
156  foundNegativeChild = true;
157 
158  if ( node.m_modePromptDecision ) {
159  if ( node.m_modeOR && foundPositiveChild ) {
160  decision = 1;
161  break;
162  } else if ( !node.m_modeOR && foundNegativeChild ) {
163  decision = 0;
164  break;
165  }
166  } else {
167  if ( foundNonResolvedChild ) break;
168  }
169  } // end monitoring children
170 
171  if ( !foundNonResolvedChild && decision == -1 ) {
172  if ( node.m_modeOR ) { // OR
173  if ( foundPositiveChild )
174  decision = 1;
175  else
176  decision = 0;
177  } else { // AND
178  if ( foundNegativeChild )
179  decision = 0;
180  else
181  decision = 1;
182  }
183  }
184 
185  if ( node.m_allPass && !foundNonResolvedChild ) decision = 1;
186 
187  if ( decision != -1 ) {
188  m_slot->controlFlowState[node.getNodeIndex()] = decision;
189  return true;
190  }
191  return false;
192  }
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 203 of file PRGraphVisitors.cpp.

204  {
205 
206  bool result = false;
207 
208  auto& states = m_slot->algsStates;
209  auto& state = states[node.getAlgoIndex()];
210 
211  // Promote with INITIAL->CR
212  if ( State::INITIAL == state ) states.updateState( node.getAlgoIndex(), State::CONTROLREADY ).ignore();
213 
214  // Try to promote with CR->DR
215  if ( State::CONTROLREADY == state ) {
216  auto promoter = DataReadyPromoter( *m_slot, m_cause, m_trace );
217  result = promoter.visit( node );
218  } else {
219  result = true;
220  }
221 
222  // return true only when an algorithm is not lower than DR in its FSM
223  // i.e., the visitor has done everything it could with this algorithm
224  return result;
225  }
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 132 of file PRGraphVisitors.cpp.

133  {
134 
135  if ( m_slot->controlFlowState[node.getNodeIndex()] != -1 ) return false;
136  return true;
137  }
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 195 of file PRGraphVisitors.cpp.

196  {
197 
198  if ( m_slot->controlFlowState[node.getNodeIndex()] != -1 ) return false;
199  return true;
200  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43

Member Data Documentation

Cause concurrency::Supervisor::m_cause

Definition at line 73 of file PRGraphVisitors.h.

EventSlot* concurrency::Supervisor::m_slot

Definition at line 72 of file PRGraphVisitors.h.

bool concurrency::Supervisor::m_trace

Definition at line 74 of file PRGraphVisitors.h.


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