The Gaudi Framework  v32r2 (46d42edc)
concurrency::DataReadyPromoter Class Reference

#include <src/PRGraph/Visitors/Promoters.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
 
virtual bool visit (DecisionNode &)
 
virtual bool visit (AlgorithmNode &)
 
virtual bool visit (DataNode &)
 
virtual bool visit (ConditionNode &)
 
virtual bool visitEnter (DecisionNode &) const
 
virtual bool visitEnter (AlgorithmNode &) const
 
virtual bool visitEnter (DataNode &) const
 
virtual bool visitEnter (ConditionNode &) const
 
- 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 Promoters.h.

Constructor & Destructor Documentation

◆ DataReadyPromoter()

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

Constructor.

Definition at line 14 of file Promoters.h.

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

Member Function Documentation

◆ visit() [1/7]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 16 of file IGraphVisitor.h.

16 { return true; };

◆ visit() [2/7]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 19 of file IGraphVisitor.h.

19 { return true; };

◆ visit() [3/7]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 22 of file IGraphVisitor.h.

22 { return true; };

◆ visit() [4/7]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 25 of file IGraphVisitor.h.

25 { return true; };

◆ visit() [5/7]

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 22 of file Promoters.cpp.

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

◆ visit() [6/7]

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 54 of file Promoters.cpp.

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

◆ visit() [7/7]

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 90 of file Promoters.cpp.

90  {
91  /* Implements 'requester' strategy, i.e., requests this ConditionNode to be loaded
92  * by its associated ConditionAlgorithm */
93 
94  auto promoter = Supervisor( *m_slot, m_cause, m_trace );
95 
96  for ( auto condAlg : node.getProducers() ) condAlg->accept( promoter );
97 
98  // this method is called if, and only if, this ConditionNode is not yet produced.
99  // thus, by definition, this ConditionNode is not yet available at this moment
100  return false;
101  }

◆ visitEnter() [1/7]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 24 of file IGraphVisitor.h.

24 { return true; };

◆ visitEnter() [2/7]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 15 of file IGraphVisitor.h.

15 { return true; };

◆ visitEnter() [3/7]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 21 of file IGraphVisitor.h.

21 { return true; };

◆ visitEnter() [4/7]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 18 of file IGraphVisitor.h.

18 { return true; };

◆ visitEnter() [5/7]

bool concurrency::DataReadyPromoter::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 14 of file Promoters.cpp.

14  {
15 
16  if ( AState::CONTROLREADY != m_slot->algsStates[node.getAlgoIndex()] ) return false;
17 
18  return true;
19  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:75

◆ visitEnter() [6/7]

bool concurrency::DataReadyPromoter::visitEnter ( DataNode ) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 51 of file Promoters.cpp.

51 { return true; }

◆ visitEnter() [7/7]

bool concurrency::DataReadyPromoter::visitEnter ( ConditionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 81 of file Promoters.cpp.

81  {
82 
83  if ( node.m_condSvc->isValidID( *( m_slot->eventContext ), node.getPath() ) )
84  return false; // do not enter this ConditionNode if the condition has bee already loaded
85 
86  return true;
87  }
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition: EventSlot.h:73

Member Data Documentation

◆ m_cause

Cause concurrency::DataReadyPromoter::m_cause

Definition at line 33 of file Promoters.h.

◆ m_slot

EventSlot* concurrency::DataReadyPromoter::m_slot

Definition at line 32 of file Promoters.h.

◆ m_trace

bool concurrency::DataReadyPromoter::m_trace

Definition at line 34 of file Promoters.h.


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