diff options
author | Narumol Prangnawarat <narumol.prangnawarat@arm.com> | 2019-09-24 17:23:16 +0100 |
---|---|---|
committer | Narumol Prangnawarat <narumol.prangnawarat@arm.com> | 2019-09-26 22:52:32 +0100 |
commit | 404b27569523f4cdd49752e7ae1633e359ba2190 (patch) | |
tree | b2acd65aae6b285cbacfafe7a83b8873a1a5e79e /src/profiling/SendCounterPacket.hpp | |
parent | e4ffe399de3445a1ecaf0ea8da7ff4f06ec878d3 (diff) | |
download | armnn-404b27569523f4cdd49752e7ae1633e359ba2190.tar.gz |
IVGCVSW-3902 Create IReadOnlyPacketBuffer, IPacketBuffer and IBufferManager interfaces
* Create IReadOnlyPacketBuffer, IPacketBuffer and IBufferManager interfaces
* Add Read and Write util functions that use IPacketBuffer
* Add MockBufferManager using IBufferManager for testing
* Modify SendCounterPacket to use IBufferManager
* Modify MockStreamCounterBuffer to use IBufferManager
* Remove IBufferWrapper and MockBuffer
* Add MockPacketBuffer for testing
* Modify unit tests to use the new interfaces
Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com>
Change-Id: Ib86768187e032f07169aa39367a418b7665c9f03
Diffstat (limited to 'src/profiling/SendCounterPacket.hpp')
-rw-r--r-- | src/profiling/SendCounterPacket.hpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/profiling/SendCounterPacket.hpp b/src/profiling/SendCounterPacket.hpp index 8dd44ecd81..c57546d907 100644 --- a/src/profiling/SendCounterPacket.hpp +++ b/src/profiling/SendCounterPacket.hpp @@ -5,7 +5,7 @@ #pragma once -#include "IBufferWrapper.hpp" +#include "IBufferManager.hpp" #include "ISendCounterPacket.hpp" #include "ICounterDirectory.hpp" #include "IProfilingConnection.hpp" @@ -31,9 +31,9 @@ public: using IndexValuePairsVector = std::vector<std::pair<uint16_t, uint32_t>>; - SendCounterPacket(IProfilingConnection& profilingConnection, IBufferWrapper& buffer) + SendCounterPacket(IProfilingConnection& profilingConnection, IBufferManager& buffer) : m_ProfilingConnection(profilingConnection) - , m_Buffer(buffer) + , m_BufferManager(buffer) , m_IsRunning(false) , m_KeepRunning(false) {} @@ -63,15 +63,25 @@ private: template <typename ExceptionType> void CancelOperationAndThrow(const std::string& errorMessage) { - // Cancel the operation - m_Buffer.Commit(0); + // Throw a runtime exception with the given error message + throw ExceptionType(errorMessage); + } + + template <typename ExceptionType> + void CancelOperationAndThrow(std::unique_ptr<IPacketBuffer>& writerBuffer, const std::string& errorMessage) + { + if (writerBuffer != nullptr) + { + // Cancel the operation + m_BufferManager.Release(writerBuffer); + } // Throw a runtime exception with the given error message throw ExceptionType(errorMessage); } IProfilingConnection& m_ProfilingConnection; - IBufferWrapper& m_Buffer; + IBufferManager& m_BufferManager; std::mutex m_WaitMutex; std::condition_variable m_WaitCondition; std::thread m_SendThread; |