diff options
author | Narumol Prangnawarat <narumol.prangnawarat@arm.com> | 2019-09-30 16:20:20 +0100 |
---|---|---|
committer | Narumol Prangnawarat <narumol.prangnawarat@arm.com> | 2019-10-04 10:13:25 +0100 |
commit | 0ec068f220daf03049a9ffb5ac53118162f50106 (patch) | |
tree | bf0673657c6ff328a70346f7fb4f714143af17b6 /src/profiling/SendCounterPacket.hpp | |
parent | 6b0f3c6d7025fb26bd2a7733dbfba02afaa44313 (diff) | |
download | armnn-0ec068f220daf03049a9ffb5ac53118162f50106.tar.gz |
IVGCVSW-3904 Add more unit tests for send thread with BufferManager
* Add timeout parameter to wait for readable data
* Write all readable data to the profiling connection when ready to read
* Set ready to read when buffer exhaust
* Ensure that readable data get written to profiling connection
before the send thread is stopped
* Add MockWriteProfilingConnection to be able to test WritePacket
* Refactor BufferManager and the unit tests
Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com>
Change-Id: I80ae01bd8d0119a3a3a957069ae8ac521c005a12
Diffstat (limited to 'src/profiling/SendCounterPacket.hpp')
-rw-r--r-- | src/profiling/SendCounterPacket.hpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/profiling/SendCounterPacket.hpp b/src/profiling/SendCounterPacket.hpp index c57546d907..748371b9fa 100644 --- a/src/profiling/SendCounterPacket.hpp +++ b/src/profiling/SendCounterPacket.hpp @@ -9,11 +9,13 @@ #include "ISendCounterPacket.hpp" #include "ICounterDirectory.hpp" #include "IProfilingConnection.hpp" +#include "ProfilingUtils.hpp" #include <atomic> +#include <condition_variable> #include <mutex> #include <thread> -#include <condition_variable> +#include <type_traits> namespace armnn { @@ -31,11 +33,12 @@ public: using IndexValuePairsVector = std::vector<std::pair<uint16_t, uint32_t>>; - SendCounterPacket(IProfilingConnection& profilingConnection, IBufferManager& buffer) + SendCounterPacket(IProfilingConnection& profilingConnection, IBufferManager& buffer, int timeout = 1) : m_ProfilingConnection(profilingConnection) , m_BufferManager(buffer) , m_IsRunning(false) , m_KeepRunning(false) + , m_Timeout(timeout) {} ~SendCounterPacket() { Stop(); } @@ -70,6 +73,10 @@ private: template <typename ExceptionType> void CancelOperationAndThrow(std::unique_ptr<IPacketBuffer>& writerBuffer, const std::string& errorMessage) { + if (std::is_same<ExceptionType, armnn::profiling::BufferExhaustion>::value) + { + SetReadyToRead(); + } if (writerBuffer != nullptr) { // Cancel the operation @@ -80,6 +87,8 @@ private: throw ExceptionType(errorMessage); } + void FlushBuffer(); + IProfilingConnection& m_ProfilingConnection; IBufferManager& m_BufferManager; std::mutex m_WaitMutex; @@ -87,6 +96,7 @@ private: std::thread m_SendThread; std::atomic<bool> m_IsRunning; std::atomic<bool> m_KeepRunning; + int m_Timeout; protected: // Helper methods, protected for testing |