aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/ProfilingService.cpp
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2019-10-14 12:31:10 +0100
committerJim Flynn <jim.flynn@arm.com>2019-10-14 14:59:07 +0100
commit53e469915bc6552c0d79cb6461512c7c1168ee2d (patch)
tree5c160326845c1e294ce88a30e0ffbb33436a3593 /src/profiling/ProfilingService.cpp
parent262578500338274b5fa0bcfeb2d72c13e717f4ff (diff)
downloadarmnn-53e469915bc6552c0d79cb6461512c7c1168ee2d.tar.gz
IVGCVSW-3972 Implement the Disconnect functionality
* Added Disconnect method to the ProfilingService class * Added unit test Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Signed-off-by: Jim Flynn <jim.flynn@arm.com> Change-Id: I5cc57abd3e1239cdf8afe21ee4883c1f73cd0e80
Diffstat (limited to 'src/profiling/ProfilingService.cpp')
-rw-r--r--src/profiling/ProfilingService.cpp43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
index 79184416cd..b481695d49 100644
--- a/src/profiling/ProfilingService.cpp
+++ b/src/profiling/ProfilingService.cpp
@@ -103,6 +103,26 @@ void ProfilingService::Update()
}
}
+void ProfilingService::Disconnect()
+{
+ ProfilingState currentState = m_StateMachine.GetCurrentState();
+ switch (currentState)
+ {
+ case ProfilingState::Uninitialised:
+ case ProfilingState::NotConnected:
+ case ProfilingState::WaitingForAck:
+ return; // NOP
+ case ProfilingState::Active:
+ // Stop the command thread (if running)
+ Stop();
+
+ break;
+ default:
+ throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1")
+ % static_cast<int>(currentState)));
+ }
+}
+
const ICounterDirectory& ProfilingService::GetCounterDirectory() const
{
return m_CounterDirectory;
@@ -244,7 +264,18 @@ void ProfilingService::InitializeCounterValue(uint16_t counterUid)
void ProfilingService::Reset()
{
// Reset the profiling service
+ Stop();
+ // ...then delete all the counter data and configuration...
+ m_CounterIndex.clear();
+ m_CounterValues.clear();
+ m_CounterDirectory.Clear();
+ // ...finally reset the profiling state machine
+ m_StateMachine.Reset();
+}
+
+void ProfilingService::Stop()
+{
// The order in which we reset/stop the components is not trivial!
// First stop the threads (Command Handler first)...
@@ -253,15 +284,13 @@ void ProfilingService::Reset()
m_PeriodicCounterCapture.Stop();
// ...then destroy the profiling connection...
+ if (m_ProfilingConnection != nullptr && m_ProfilingConnection->IsOpen())
+ {
+ m_ProfilingConnection->Close();
+ }
m_ProfilingConnection.reset();
- // ...then delete all the counter data and configuration...
- m_CounterIndex.clear();
- m_CounterValues.clear();
- m_CounterDirectory.Clear();
-
- // ...finally reset the profiling state machine
- m_StateMachine.Reset();
+ m_StateMachine.TransitionToState(ProfilingState::NotConnected);
}
inline void ProfilingService::CheckCounterUid(uint16_t counterUid) const