From 54fb957c9640d61ab575d7acfc4c430a15123315 Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Wed, 2 Oct 2019 12:50:57 +0100 Subject: IVGCVSW-3937 Add the necessary components to the ProfilingService class to process a connection to an external profiling service (e.g. gatord) * Added the required components (CommandHandlerRegistry, CommandHandler, SendCounterPacket, ...) to the ProfilingService class * Reworked the ProfilingService::Run procedure and renamed it to Update * Handling all states but Active in the Run method (future work) * Updated the unit and tests accordingly * Added component tests to check that the Connection Acknowledged packet is handled correctly * Added test util classes, made the default constructor/destructor protected to superclass a ProfilingService object * Added IProfilingConnectionFactory interface Signed-off-by: Matteo Martincigh Change-Id: I010d94b18980c9e6394253f4b2bbe4fe5bb3fe4f --- src/profiling/ProfilingStateMachine.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/profiling/ProfilingStateMachine.cpp') diff --git a/src/profiling/ProfilingStateMachine.cpp b/src/profiling/ProfilingStateMachine.cpp index 5af5bfbed0..9d3a81f64a 100644 --- a/src/profiling/ProfilingStateMachine.cpp +++ b/src/profiling/ProfilingStateMachine.cpp @@ -35,50 +35,50 @@ ProfilingState ProfilingStateMachine::GetCurrentState() const void ProfilingStateMachine::TransitionToState(ProfilingState newState) { - ProfilingState expectedState = m_State.load(std::memory_order::memory_order_relaxed); + ProfilingState currentState = m_State.load(std::memory_order::memory_order_relaxed); switch (newState) { case ProfilingState::Uninitialised: do { - if (!IsOneOfStates(expectedState, ProfilingState::Uninitialised)) + if (!IsOneOfStates(currentState, ProfilingState::Uninitialised)) { - ThrowStateTransitionException(expectedState, newState); + ThrowStateTransitionException(currentState, newState); } } - while (!m_State.compare_exchange_strong(expectedState, newState, std::memory_order::memory_order_relaxed)); + while (!m_State.compare_exchange_strong(currentState, newState, std::memory_order::memory_order_relaxed)); break; case ProfilingState::NotConnected: do { - if (!IsOneOfStates(expectedState, ProfilingState::Uninitialised, ProfilingState::NotConnected, + if (!IsOneOfStates(currentState, ProfilingState::Uninitialised, ProfilingState::NotConnected, ProfilingState::Active)) { - ThrowStateTransitionException(expectedState, newState); + ThrowStateTransitionException(currentState, newState); } } - while (!m_State.compare_exchange_strong(expectedState, newState, std::memory_order::memory_order_relaxed)); + while (!m_State.compare_exchange_strong(currentState, newState, std::memory_order::memory_order_relaxed)); break; case ProfilingState::WaitingForAck: do { - if (!IsOneOfStates(expectedState, ProfilingState::NotConnected, ProfilingState::WaitingForAck)) + if (!IsOneOfStates(currentState, ProfilingState::NotConnected, ProfilingState::WaitingForAck)) { - ThrowStateTransitionException(expectedState, newState); + ThrowStateTransitionException(currentState, newState); } } - while (!m_State.compare_exchange_strong(expectedState, newState, std::memory_order::memory_order_relaxed)); + while (!m_State.compare_exchange_strong(currentState, newState, std::memory_order::memory_order_relaxed)); break; case ProfilingState::Active: do { - if (!IsOneOfStates(expectedState, ProfilingState::WaitingForAck, ProfilingState::Active)) + if (!IsOneOfStates(currentState, ProfilingState::WaitingForAck, ProfilingState::Active)) { - ThrowStateTransitionException(expectedState, newState); + ThrowStateTransitionException(currentState, newState); } } - while (!m_State.compare_exchange_strong(expectedState, newState, std::memory_order::memory_order_relaxed)); + while (!m_State.compare_exchange_strong(currentState, newState, std::memory_order::memory_order_relaxed)); break; default: break; -- cgit v1.2.1