From 0ec068f220daf03049a9ffb5ac53118162f50106 Mon Sep 17 00:00:00 2001 From: Narumol Prangnawarat Date: Mon, 30 Sep 2019 16:20:20 +0100 Subject: 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 Change-Id: I80ae01bd8d0119a3a3a957069ae8ac521c005a12 --- src/profiling/BufferManager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/profiling/BufferManager.cpp') diff --git a/src/profiling/BufferManager.cpp b/src/profiling/BufferManager.cpp index dbf4466bbb..6ac3ee17d1 100644 --- a/src/profiling/BufferManager.cpp +++ b/src/profiling/BufferManager.cpp @@ -29,16 +29,17 @@ BufferManager::BufferManager(unsigned int numberOfBuffers, unsigned int maxPacke std::unique_ptr BufferManager::Reserve(unsigned int requestedSize, unsigned int& reservedSize) { + reservedSize = 0; std::unique_lock availableListLock(m_AvailableMutex, std::defer_lock); if (requestedSize > m_MaxBufferSize) { - throw armnn::InvalidArgumentException("The maximum buffer size that can be requested is [" + - std::to_string(m_MaxBufferSize) + "] bytes"); + return nullptr; } availableListLock.lock(); if (m_AvailableList.empty()) { - throw armnn::profiling::BufferExhaustion("Buffer not available"); + availableListLock.unlock(); + return nullptr; } std::unique_ptr buffer = std::move(m_AvailableList.back()); m_AvailableList.pop_back(); -- cgit v1.2.1