The Gaudi Framework  v31r0 (aeb156f0)
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 10 of file PRGraphVisitors.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 13 of file PRGraphVisitors.h.

Member Function Documentation

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 21 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 53 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 89 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 13 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 50 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 80 of file PRGraphVisitors.cpp.

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

Member Data Documentation

Cause concurrency::DataReadyPromoter::m_cause

Definition at line 32 of file PRGraphVisitors.h.

EventSlot* concurrency::DataReadyPromoter::m_slot

Definition at line 31 of file PRGraphVisitors.h.

bool concurrency::DataReadyPromoter::m_trace

Definition at line 33 of file PRGraphVisitors.h.


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