The Gaudi Framework  v30r2 (9eca68f7)
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 24 of file PRGraphVisitors.cpp.

25  {
26 
27  bool result = true; // return true if this algorithm has no data inputs
28 
29  for ( auto dataNode : node.getInputDataNodes() ) {
30 
31  result = dataNode->accept( *this );
32 
33  // With ConditionNodes, one may decide NOT to break here so that associated
34  // ConditionAlgorithms are scheduled ASAP. This behavior can be made configurable
35  if ( !result ) break; // skip checking other inputs if this input was not produced yet
36  }
37 
38  if ( result ) {
39  m_slot->algsStates.updateState( node.getAlgoIndex(), State::DATAREADY ).ignore();
40 
41  // Inform parent slot if there is one
42  if ( m_slot->parentSlot ) {
44  }
45 
46  if ( m_trace ) {
47  auto sourceNode = ( m_cause.m_source == Cause::source::Task )
48  ? node.m_graph->getAlgorithmNode( m_cause.m_sourceName )
49  : nullptr;
50  node.m_graph->addEdgeToPrecTrace( sourceNode, &node );
51  }
52  }
53 
54  // return true only if an algorithm is promoted to DR
55  return result;
56  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:50
EventContext * eventContext
Cache for the eventContext.
Definition: EventSlot.h:45
T push_back(T...args)
std::vector< std::pair< EventContext *, int > > subSlotAlgsReady
Quick lookup for data-ready algorithms in sub-slots (top level only)
Definition: EventSlot.h:62
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:60
T make_pair(T...args)
std::string m_sourceName
StatusCode updateState(unsigned int iAlgo, State newState)
bool concurrency::DataReadyPromoter::visit ( DataNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 62 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 100 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 15 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 59 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 90 of file PRGraphVisitors.cpp.

91  {
92 
93  if ( node.m_condSvc->isValidID( *( m_slot->eventContext ), node.getPath() ) )
94  return false; // do not enter this ConditionNode if the condition has bee already loaded
95 
96  return true;
97  }
EventContext * eventContext
Cache for the eventContext.
Definition: EventSlot.h:45

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: