diff options
author | Finn Williams <Finn.Williams@arm.com> | 2019-12-19 17:05:18 +0000 |
---|---|---|
committer | Finn Williams <Finn.Williams@arm.com> | 2020-01-14 12:39:05 +0000 |
commit | 09ad6f909f25aef02b7f53bba320b534b9260786 (patch) | |
tree | e69f6d9d4b15b0c7e106c5f6749dd77586247a75 /src/profiling/FileOnlyProfilingConnection.cpp | |
parent | f90c56d72de4848a2dc5844a97458aaf09df07c2 (diff) | |
download | armnn-09ad6f909f25aef02b7f53bba320b534b9260786.tar.gz |
IVGCVSW-4229 Fix Intermittent failures in ExternalProfiling
* Added a BufferManager.Reset() method to prevent packets being retained after a test
* Fixed a bug causing the send thread to wait needlessly before moving to active state
* Refactored SendCoundPacketTests and ProfilingTests test helper classes
* Fixed issue where WaitForPacketSent could miss a notification and timeout
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: I353a652260c2f7dd465baa9e979e22f50f3ca6a7
Diffstat (limited to 'src/profiling/FileOnlyProfilingConnection.cpp')
-rw-r--r-- | src/profiling/FileOnlyProfilingConnection.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/profiling/FileOnlyProfilingConnection.cpp b/src/profiling/FileOnlyProfilingConnection.cpp index 75862616b9..1db8030313 100644 --- a/src/profiling/FileOnlyProfilingConnection.cpp +++ b/src/profiling/FileOnlyProfilingConnection.cpp @@ -166,13 +166,16 @@ bool FileOnlyProfilingConnection::WritePacket(const unsigned char* buffer, uint3 Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout) { std::unique_lock<std::mutex> lck(m_PacketAvailableMutex); - if (m_PacketQueue.empty()) + + // Here we are using m_PacketQueue.empty() as a predicate variable + // The conditional variable will wait until packetQueue is not empty or until a timeout + if(!m_ConditionPacketAvailable.wait_for(lck, + std::chrono::milliseconds(timeout), + [&]{return !m_PacketQueue.empty();})) { - if(m_ConditionPacketAvailable.wait_for(lck, std::chrono::milliseconds(timeout)) == std::cv_status::timeout) - { - throw armnn::TimeoutException("Thread has timed out as per requested time limit"); - } + throw armnn::TimeoutException("Thread has timed out as per requested time limit"); } + Packet returnedPacket = std::move(m_PacketQueue.front()); m_PacketQueue.pop(); return returnedPacket; |