The Gaudi Framework  v30r1 (5d4f4ae2)
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 22 of file PRGraphVisitors.cpp.

23  {
24 
25  bool result = true; // return true if this algorithm has no data inputs
26 
27  for ( auto dataNode : node.getInputDataNodes() ) {
28 
29  result = dataNode->accept( *this );
30 
31  // With ConditionNodes, one may decide NOT to break here so that associated
32  // ConditionAlgorithms are scheduled ASAP. This behavior can be made configurable
33  if ( !result ) break; // skip checking other inputs if this input was not produced yet
34  }
35 
36  if ( result ) {
37  m_slot->algsStates.updateState( node.getAlgoIndex(), State::DATAREADY ).ignore();
38 
39  // Inform parent slot if there is one
40  if ( m_slot->parentSlot ) {
42  }
43 
44  if ( m_trace ) {
45  auto sourceNode = ( m_cause.m_source == Cause::source::Task )
46  ? node.m_graph->getAlgorithmNode( m_cause.m_sourceName )
47  : nullptr;
48  node.m_graph->addEdgeToPrecTrace( sourceNode, &node );
49  }
50  }
51 
52  // return true only if an algorithm is promoted to DR
53  return result;
54  }
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 60 of file PRGraphVisitors.cpp.

61  {
62  /* Implements 'observer' strategy, i.e., only check if producer of this DataNode
63  * has been already executed or not */
64 
65  auto const& producers = node.getProducers();
66  for ( auto algoNode : producers ) {
67  const auto& state = m_slot->algsStates[algoNode->getAlgoIndex()];
68  if ( State::EVTACCEPTED == state || State::EVTREJECTED == state ) {
69  return true; // skip checking other producers if one was found to be executed
70  }
71  }
72 
73  // Check parent slot if necessary
74  if ( m_slot->parentSlot ) {
75  for ( auto algoNode : producers ) {
76  const auto& state = m_slot->parentSlot->algsStates[algoNode->getAlgoIndex()];
77  if ( State::EVTACCEPTED == state || State::EVTREJECTED == state ) {
78  return true; // skip checking other producers if one was found to be executed
79  }
80  }
81  }
82 
83  // return true only if this DataNode is produced
84  return false;
85  }
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 98 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 13 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 57 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 88 of file PRGraphVisitors.cpp.

89  {
90 
91  if ( node.m_condSvc->isValidID( *( m_slot->eventContext ), node.getPath() ) )
92  return false; // do not enter this ConditionNode if the condition has bee already loaded
93 
94  return true;
95  }
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: