aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/SendCounterPacket.hpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-10 14:08:21 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-11 16:33:29 +0100
commite848538efbdf01aa0b067da942c3c214f8e62826 (patch)
treed700239f1316a098849fcfc39ec70e926f86fd62 /src/profiling/SendCounterPacket.hpp
parentf982deaefbe5fe5814487b27f7099829839b8666 (diff)
downloadarmnn-e848538efbdf01aa0b067da942c3c214f8e62826.tar.gz
IVGCVSW-3964 Implement the Periodic Counter Selection command handler
* Improved the PeriodicCounterPacket class to handle errors properly * Improved the PeriodicCounterSelectionCommandHandler to handle invalid counter UIDs in the selection packet * Added the Periodic Counter Selection command handler to the ProfilingService class * Code refactoring and added comments * Added WaitForPacketSent method to the SendCounterPacket class to allow waiting for the packets to be sent (useful in the unit tests) * Added unit tests and updated the old ones accordingly * Fixed threading issues with a number of unit tests Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I271b7b0bfa801d88fe1725b934d24e30cd839ed7
Diffstat (limited to 'src/profiling/SendCounterPacket.hpp')
-rw-r--r--src/profiling/SendCounterPacket.hpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/profiling/SendCounterPacket.hpp b/src/profiling/SendCounterPacket.hpp
index 9361efbc74..e1a42aa496 100644
--- a/src/profiling/SendCounterPacket.hpp
+++ b/src/profiling/SendCounterPacket.hpp
@@ -65,6 +65,14 @@ public:
void Stop(bool rethrowSendThreadExceptions = true);
bool IsRunning() { return m_IsRunning.load(); }
+ void WaitForPacketSent()
+ {
+ std::unique_lock<std::mutex> lock(m_PacketSentWaitMutex);
+
+ // Blocks until notified that at least a packet has been sent
+ m_PacketSentWaitCondition.wait(lock);
+ }
+
private:
void Send(IProfilingConnection& profilingConnection);
@@ -93,7 +101,7 @@ private:
throw ExceptionType(errorMessage);
}
- void FlushBuffer(IProfilingConnection& profilingConnection);
+ void FlushBuffer(IProfilingConnection& profilingConnection, bool notifyWatchers = true);
ProfilingStateMachine& m_StateMachine;
IBufferManager& m_BufferManager;
@@ -104,6 +112,8 @@ private:
std::atomic<bool> m_IsRunning;
std::atomic<bool> m_KeepRunning;
std::exception_ptr m_SendThreadException;
+ std::mutex m_PacketSentWaitMutex;
+ std::condition_variable m_PacketSentWaitCondition;
protected:
// Helper methods, protected for testing