diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-10-09 16:47:04 +0100 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-10-09 17:44:11 +0100 |
commit | d0613b56cea7eba0604e0548bddffd773a4eb554 (patch) | |
tree | 18e5a28c346018340910c456eedd56717ab01c9c /src/profiling/ProfilingService.cpp | |
parent | 09ca49cdcfbe377da979a19df9bcdb7cbffc7b50 (diff) | |
download | armnn-d0613b56cea7eba0604e0548bddffd773a4eb554.tar.gz |
IVGCVSW-3937 Improve the Connection Acknowledged Handler
* The Connection Acknowledged Handler should report an error
is it's called while in a wrong state
* Stopping the threads in the ProfilingService before having
to start them again
* Updated the unit tests to check the changes
* Removed unnecessary Packet.cpp file
* Fixed memory leak
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Change-Id: I8c4d33b4d97994df86fe6c9f8c659f880ec64c16
Diffstat (limited to 'src/profiling/ProfilingService.cpp')
-rw-r--r-- | src/profiling/ProfilingService.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index 19cf9cb58e..693f8337db 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -47,7 +47,11 @@ void ProfilingService::Update() m_StateMachine.TransitionToState(ProfilingState::NotConnected); break; case ProfilingState::NotConnected: - BOOST_ASSERT(m_ProfilingConnectionFactory); + // Stop the command thread (if running) + m_CommandHandler.Stop(); + + // Stop the send thread (if running) + m_SendCounterPacket.Stop(false); // Reset any existing profiling connection m_ProfilingConnection.reset(); @@ -55,13 +59,13 @@ void ProfilingService::Update() try { // Setup the profiling connection - //m_ProfilingConnection = m_ProfilingConnectionFactory.GetProfilingConnection(m_Options); + BOOST_ASSERT(m_ProfilingConnectionFactory); m_ProfilingConnection = m_ProfilingConnectionFactory->GetProfilingConnection(m_Options); } catch (const Exception& e) { BOOST_LOG_TRIVIAL(warning) << "An error has occurred when creating the profiling connection: " - << e.what(); + << e.what() << std::endl; } // Move to the next state @@ -229,13 +233,23 @@ void ProfilingService::InitializeCounterValue(uint16_t counterUid) void ProfilingService::Reset() { // Reset the profiling service - m_CounterDirectory.Clear(); + + // The order in which we reset/stop the components is not trivial! + + // First stop the threads (Command Handler first)... + m_CommandHandler.Stop(); + m_SendCounterPacket.Stop(false); + + // ...then destroy the profiling connection... m_ProfilingConnection.reset(); - m_StateMachine.Reset(); + + // ...then delete all the counter data and configuration... m_CounterIndex.clear(); m_CounterValues.clear(); - m_CommandHandler.Stop(); - m_SendCounterPacket.Stop(false); + m_CounterDirectory.Clear(); + + // ...finally reset the profiling state machine + m_StateMachine.Reset(); } } // namespace profiling |