The Gaudi Framework  v36r1 (3e2fb5a8)
AlgsExecutionStates Class Referencefinal

#include <GaudiKernel/AlgsExecutionStates.h>

Collaboration diagram for AlgsExecutionStates:

Classes

class  Iterator
 

Public Types

enum  State : uint8_t {
  INITIAL = 0, CONTROLREADY = 1, DATAREADY = 2, RESOURCELESS = 3,
  SCHEDULED = 4, EVTACCEPTED = 5, EVTREJECTED = 6, ERROR = 7,
  MAXVALUE = 8
}
 Execution states of the algorithms Must have contiguous integer values 0, 1... More...
 

Public Member Functions

 AlgsExecutionStates (unsigned int algsNumber, SmartIF< IMessageSvc > MS)
 
StatusCode set (unsigned int iAlgo, State newState)
 
void reset ()
 
bool contains (State state) const
 check if the collection contains at least one state of requested type More...
 
bool containsAny (std::initializer_list< State > l) const
 check if the collection contains at least one state of any listed types More...
 
bool containsOnly (std::initializer_list< State > l) const
 check if the collection contains only states of listed types More...
 
const Stateoperator[] (unsigned int i) const
 
size_t size () const
 
size_t sizeOfSubset (State state) const
 
Iterator begin (State kind)
 
Iterator end (State kind)
 

Private Member Functions

MsgStream log ()
 

Private Attributes

std::vector< Statem_states
 
SmartIF< IMessageSvcm_MS
 

Detailed Description

The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single event. It is used by the concurrent schedulers

Author
Benedikt Hegner
Danilo Piparo
Version
1.0

Definition at line 36 of file AlgsExecutionStates.h.

Member Enumeration Documentation

◆ State

Execution states of the algorithms Must have contiguous integer values 0, 1...

N

Enumerator
INITIAL 
CONTROLREADY 
DATAREADY 
RESOURCELESS 
SCHEDULED 
EVTACCEPTED 
EVTREJECTED 
ERROR 
MAXVALUE 

Definition at line 40 of file AlgsExecutionStates.h.

40  : uint8_t {
41  INITIAL = 0,
42  CONTROLREADY = 1,
43  DATAREADY = 2,
44  RESOURCELESS = 3,
45  SCHEDULED = 4,
46  EVTACCEPTED = 5,
47  EVTREJECTED = 6,
48  ERROR = 7,
49  MAXVALUE = 8 // Allows loop over all states
50  };

Constructor & Destructor Documentation

◆ AlgsExecutionStates()

AlgsExecutionStates::AlgsExecutionStates ( unsigned int  algsNumber,
SmartIF< IMessageSvc MS 
)
inline

Definition at line 52 of file AlgsExecutionStates.h.

53  : m_states( algsNumber, INITIAL ), m_MS( std::move( MS ) ){};

Member Function Documentation

◆ begin()

Iterator AlgsExecutionStates::begin ( State  kind)
inline

Definition at line 116 of file AlgsExecutionStates.h.

116 { return {kind, m_states, m_states.begin()}; }

◆ contains()

bool AlgsExecutionStates::contains ( State  state) const
inline

check if the collection contains at least one state of requested type

Definition at line 60 of file AlgsExecutionStates.h.

60 { return std::find( m_states.begin(), m_states.end(), state ) != m_states.end(); }

◆ containsAny()

bool AlgsExecutionStates::containsAny ( std::initializer_list< State l) const
inline

check if the collection contains at least one state of any listed types

Definition at line 63 of file AlgsExecutionStates.h.

63  {
64  return std::find_first_of( m_states.begin(), m_states.end(), l.begin(), l.end() ) != m_states.end();
65  }

◆ containsOnly()

bool AlgsExecutionStates::containsOnly ( std::initializer_list< State l) const
inline

check if the collection contains only states of listed types

Definition at line 68 of file AlgsExecutionStates.h.

68  {
69  return std::all_of( m_states.begin(), m_states.end(),
70  [l]( State s ) { return std::find( l.begin(), l.end(), s ) != l.end(); } );
71  };

◆ end()

Iterator AlgsExecutionStates::end ( State  kind)
inline

Definition at line 117 of file AlgsExecutionStates.h.

117 { return {kind, m_states, m_states.end()}; }

◆ log()

MsgStream AlgsExecutionStates::log ( )
inlineprivate

Definition at line 85 of file AlgsExecutionStates.h.

85 { return {m_MS, "AlgsExecutionStates"}; }

◆ operator[]()

const State& AlgsExecutionStates::operator[] ( unsigned int  i) const
inline

Definition at line 73 of file AlgsExecutionStates.h.

73 { return m_states.at( i ); };

◆ reset()

void AlgsExecutionStates::reset ( )
inline

Definition at line 57 of file AlgsExecutionStates.h.

◆ set()

StatusCode AlgsExecutionStates::set ( unsigned int  iAlgo,
State  newState 
)

Definition at line 23 of file AlgsExecutionStates.cpp.

23  {
24  if ( iAlgo >= m_states.size() ) {
25  log() << MSG::ERROR << "Index out of bound (" << iAlgo << " / " << m_states.size() << ")" << endmsg;
26  return StatusCode::FAILURE;
27  }
28 
29  // Allow cycling of a single state
30  if ( m_states[iAlgo] == newState ) return StatusCode::SUCCESS;
31 
32  switch ( transition( m_states[iAlgo], newState ) ) {
33  case transition( INITIAL, CONTROLREADY ):
34  [[fallthrough]];
35  case transition( CONTROLREADY, DATAREADY ):
36  [[fallthrough]];
37  case transition( DATAREADY, SCHEDULED ):
38  [[fallthrough]];
39  case transition( DATAREADY, RESOURCELESS ):
40  [[fallthrough]];
41  case transition( RESOURCELESS, SCHEDULED ):
42  [[fallthrough]];
43  case transition( SCHEDULED, ERROR ):
44  [[fallthrough]];
45  case transition( SCHEDULED, EVTACCEPTED ):
46  [[fallthrough]];
47  case transition( SCHEDULED, EVTREJECTED ):
48  m_states[iAlgo] = newState;
49  return StatusCode::SUCCESS;
50  default:
51  log() << MSG::ERROR << "[AlgIndex " << iAlgo << "] Transition from " << m_states[iAlgo] << " to " << newState
52  << " is not allowed" << endmsg;
53  m_states[iAlgo] = ERROR;
54  return StatusCode::FAILURE;
55  }
56 }

◆ size()

size_t AlgsExecutionStates::size ( ) const
inline

Definition at line 75 of file AlgsExecutionStates.h.

75 { return m_states.size(); }

◆ sizeOfSubset()

size_t AlgsExecutionStates::sizeOfSubset ( State  state) const
inline

Definition at line 77 of file AlgsExecutionStates.h.

77  {
78  return std::count_if( m_states.begin(), m_states.end(), [&]( State s ) { return s == state; } );
79  }

Member Data Documentation

◆ m_MS

SmartIF<IMessageSvc> AlgsExecutionStates::m_MS
private

Definition at line 83 of file AlgsExecutionStates.h.

◆ m_states

std::vector<State> AlgsExecutionStates::m_states
private

Definition at line 82 of file AlgsExecutionStates.h.


The documentation for this class was generated from the following files:
std::move
T move(T... args)
gaudirun.s
string s
Definition: gaudirun.py:328
AlgsExecutionStates::MAXVALUE
@ MAXVALUE
Definition: AlgsExecutionStates.h:49
std::find
T find(T... args)
std::vector::size
T size(T... args)
std::all_of
T all_of(T... args)
AlgsExecutionStates::CONTROLREADY
@ CONTROLREADY
Definition: AlgsExecutionStates.h:42
std::fill
T fill(T... args)
AlgsExecutionStates::RESOURCELESS
@ RESOURCELESS
Definition: AlgsExecutionStates.h:44
AlgsExecutionStates::m_MS
SmartIF< IMessageSvc > m_MS
Definition: AlgsExecutionStates.h:83
AlgsExecutionStates::log
MsgStream log()
Definition: AlgsExecutionStates.h:85
AlgsExecutionStates::ERROR
@ ERROR
Definition: AlgsExecutionStates.h:48
std::vector::at
T at(T... args)
AlgsExecutionStates::m_states
std::vector< State > m_states
Definition: AlgsExecutionStates.h:82
AlgsExecutionStates::SCHEDULED
@ SCHEDULED
Definition: AlgsExecutionStates.h:45
AlgsExecutionStates::EVTREJECTED
@ EVTREJECTED
Definition: AlgsExecutionStates.h:47
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
gaudirun.l
dictionary l
Definition: gaudirun.py:553
compareRootHistos.state
def state
Definition: compareRootHistos.py:468
std::vector::begin
T begin(T... args)
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
AlgsExecutionStates::DATAREADY
@ DATAREADY
Definition: AlgsExecutionStates.h:43
AlgsExecutionStates::State
State
Execution states of the algorithms Must have contiguous integer values 0, 1...
Definition: AlgsExecutionStates.h:40
AlgsExecutionStates::EVTACCEPTED
@ EVTACCEPTED
Definition: AlgsExecutionStates.h:46
std::count_if
T count_if(T... args)
std::find_first_of
T find_first_of(T... args)
std::vector::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
AlgsExecutionStates::INITIAL
@ INITIAL
Definition: AlgsExecutionStates.h:41