ArmNN
 21.02
ProfilingStateMachine Class Reference

#include <ProfilingStateMachine.hpp>

Public Member Functions

 ProfilingStateMachine ()
 
 ProfilingStateMachine (ProfilingState state)
 
ProfilingState GetCurrentState () const
 
void TransitionToState (ProfilingState newState)
 
void Reset ()
 
bool IsOneOfStates (ProfilingState state1)
 
template<typename T , typename... Args>
bool IsOneOfStates (T state1, T state2, Args... args)
 

Detailed Description

Definition at line 26 of file ProfilingStateMachine.hpp.

Constructor & Destructor Documentation

◆ ProfilingStateMachine() [1/2]

◆ ProfilingStateMachine() [2/2]

Definition at line 30 of file ProfilingStateMachine.hpp.

30 : m_State(state) {}

Member Function Documentation

◆ GetCurrentState()

◆ IsOneOfStates() [1/2]

bool IsOneOfStates ( ProfilingState  state1)
inline

Definition at line 36 of file ProfilingStateMachine.hpp.

References armnn::IgnoreUnused().

Referenced by ProfilingStateMachine::TransitionToState().

37  {
38  IgnoreUnused(state1);
39  return false;
40  }
void IgnoreUnused(Ts &&...)

◆ IsOneOfStates() [2/2]

bool IsOneOfStates ( state1,
state2,
Args...  args 
)
inline

Definition at line 43 of file ProfilingStateMachine.hpp.

44  {
45  if (state1 == state2)
46  {
47  return true;
48  }
49  else
50  {
51  return IsOneOfStates(state1, args...);
52  }
53  }

◆ Reset()

◆ TransitionToState()

void TransitionToState ( ProfilingState  newState)

Definition at line 36 of file ProfilingStateMachine.cpp.

References armnn::profiling::Active, ProfilingStateMachine::IsOneOfStates(), armnn::profiling::NotConnected, armnn::profiling::Uninitialised, and armnn::profiling::WaitingForAck.

Referenced by BOOST_AUTO_TEST_CASE(), ProfilingService::GetSendTimelinePacket(), ConnectionAcknowledgedCommandHandler::operator()(), ProfilingCurrentStateThreadImpl(), ProfilingService::TransitionToState(), and ProfilingService::Update().

37 {
38  ProfilingState currentState = m_State.load(std::memory_order::memory_order_relaxed);
39 
40  switch (newState)
41  {
43  do
44  {
45  if (!IsOneOfStates(currentState, ProfilingState::Uninitialised))
46  {
47  ThrowStateTransitionException(currentState, newState);
48  }
49  }
50  while (!m_State.compare_exchange_strong(currentState, newState, std::memory_order::memory_order_relaxed));
51  break;
53  do
54  {
57  {
58  ThrowStateTransitionException(currentState, newState);
59  }
60  }
61  while (!m_State.compare_exchange_strong(currentState, newState, std::memory_order::memory_order_relaxed));
62  break;
64  do
65  {
67  {
68  ThrowStateTransitionException(currentState, newState);
69  }
70  }
71  while (!m_State.compare_exchange_strong(currentState, newState, std::memory_order::memory_order_relaxed));
72  break;
74  do
75  {
77  {
78  ThrowStateTransitionException(currentState, newState);
79  }
80  }
81  while (!m_State.compare_exchange_strong(currentState, newState, std::memory_order::memory_order_relaxed));
82  break;
83  default:
84  break;
85  }
86 }

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