The Gaudi Framework  v30r3 (a5ef0a68)
concurrency::DataReadyPromoter Class Reference

#include <src/PRGraphVisitors.h>

Inheritance diagram for concurrency::DataReadyPromoter:
Collaboration diagram for concurrency::DataReadyPromoter:

Public Member Functions

 DataReadyPromoter (EventSlot &slot, const Cause &cause, bool ifTrace=false)
 Constructor. More...
 
bool visitEnter (AlgorithmNode &) const override
 
bool visit (AlgorithmNode &) override
 
bool visitEnter (DataNode &) const override
 
bool visit (DataNode &) override
 
bool visitEnter (ConditionNode &) const override
 
bool visit (ConditionNode &) override
 
- Public Member Functions inherited from concurrency::IGraphVisitor
virtual ~IGraphVisitor ()=default
 
virtual bool visitEnter (DecisionNode &) const
 
virtual bool visit (DecisionNode &)
 
virtual void reset ()
 

Public Attributes

EventSlotm_slot
 
Cause m_cause
 
bool m_trace
 

Detailed Description

Definition at line 11 of file PRGraphVisitors.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 15 of file PRGraphVisitors.h.

Member Function Documentation

bool concurrency::DataReadyPromoter::visit ( AlgorithmNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 23 of file PRGraphVisitors.cpp.

24  {
25 
26  bool result = true; // return true if this algorithm has no data inputs
27 
28  for ( auto dataNode : node.getInputDataNodes() ) {
29 
30  result = dataNode->accept( *this );
31 
32  // With ConditionNodes, one may decide NOT to break here so that associated
33  // ConditionAlgorithms are scheduled ASAP. This behavior can be made configurable
34  if ( !result ) break; // skip checking other inputs if this input was not produced yet
35  }
36 
37  if ( result ) {
38  m_slot->algsStates.set( node.getAlgoIndex(), AState::DATAREADY ).ignore();
39 
40  if ( m_trace ) {
41  auto sourceNode = ( m_cause.m_source == Cause::source::Task )
42  ? node.m_graph->getAlgorithmNode( m_cause.m_sourceName )
43  : nullptr;
44  node.m_graph->addEdgeToPrecTrace( sourceNode, &node );
45  }
46  }
47 
48  // return true only if an algorithm is promoted to DR
49  return result;
50  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:49
StatusCode set(unsigned int iAlgo, State newState)
std::string m_sourceName
bool concurrency::DataReadyPromoter::visit ( DataNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 56 of file PRGraphVisitors.cpp.

57  {
58  /* Implements 'observer' strategy, i.e., only check if producer of this DataNode
59  * has been already executed or not */
60 
61  auto const& producers = node.getProducers();
62  for ( auto algoNode : producers ) {
63  const auto& state = m_slot->algsStates[algoNode->getAlgoIndex()];
64  if ( AState::EVTACCEPTED == state || AState::EVTREJECTED == state ) {
65  return true; // skip checking other producers if one was found to be executed
66  }
67  }
68 
69  // Check parent slot if necessary
70  if ( m_slot->parentSlot ) {
71  for ( auto algoNode : producers ) {
72  const auto& state = m_slot->parentSlot->algsStates[algoNode->getAlgoIndex()];
73  if ( AState::EVTACCEPTED == state || AState::EVTREJECTED == state ) {
74  return true; // skip checking other producers if one was found to be executed
75  }
76  }
77  }
78 
79  // return true only if this DataNode is produced
80  return false;
81  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:49
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:59
bool concurrency::DataReadyPromoter::visit ( ConditionNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 94 of file PRGraphVisitors.cpp.

95  {
96  /* Implements 'requester' strategy, i.e., requests this ConditionNode to be loaded
97  * by its associated ConditionAlgorithm */
98 
99  auto promoter = Supervisor( *m_slot, m_cause, m_trace );
100 
101  for ( auto condAlg : node.getProducers() ) condAlg->accept( promoter );
102 
103  // this method is called if, and only if, this ConditionNode is not yet produced.
104  // thus, by definition, this ConditionNode is not yet available at this moment
105  return false;
106  }
bool concurrency::DataReadyPromoter::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 14 of file PRGraphVisitors.cpp.

15  {
16 
17  if ( AState::CONTROLREADY != m_slot->algsStates[node.getAlgoIndex()] ) return false;
18 
19  return true;
20  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:49
bool concurrency::DataReadyPromoter::visitEnter ( DataNode ) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 53 of file PRGraphVisitors.cpp.

53 { return true; }
bool concurrency::DataReadyPromoter::visitEnter ( ConditionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 84 of file PRGraphVisitors.cpp.

85  {
86 
87  if ( node.m_condSvc->isValidID( *( m_slot->eventContext ), node.getPath() ) )
88  return false; // do not enter this ConditionNode if the condition has bee already loaded
89 
90  return true;
91  }
EventContext * eventContext
Cache for the eventContext.
Definition: EventSlot.h:44

Member Data Documentation

Cause concurrency::DataReadyPromoter::m_cause

Definition at line 34 of file PRGraphVisitors.h.

EventSlot* concurrency::DataReadyPromoter::m_slot

Definition at line 33 of file PRGraphVisitors.h.

bool concurrency::DataReadyPromoter::m_trace

Definition at line 35 of file PRGraphVisitors.h.


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