aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/SendCounterPacket.hpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-07 13:05:13 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-08 10:43:50 +0100
commit5d737fb3b06c17ff6b65fb307343ca1c0c680401 (patch)
tree91c5548fd4e84ff086e57020a017982124b06c50 /src/profiling/SendCounterPacket.hpp
parentc2728f95086c54aa842e4c1dae8f3b5c290a72fa (diff)
downloadarmnn-5d737fb3b06c17ff6b65fb307343ca1c0c680401.tar.gz
IVGCVSW-3937 Update the Send thread to send out the Metadata packet
* The Send thread now automatically sends out Stream Metadata packets when the Profiling Service is in WaitingForAck state * Added a reference to the profiling state in the SendCounterPacket class * Moving the RuntimeException thrown in the Send thread to the main thread for rethrowing * The Stop method now rethrows the exception occurred in the send thread * The Stop method does not rethrow when destructing the object * Added unit tests Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: Ice7080bff63199eac84fc4fa1d37fb1a6fcdff89
Diffstat (limited to 'src/profiling/SendCounterPacket.hpp')
-rw-r--r--src/profiling/SendCounterPacket.hpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/profiling/SendCounterPacket.hpp b/src/profiling/SendCounterPacket.hpp
index ed76937cc3..9361efbc74 100644
--- a/src/profiling/SendCounterPacket.hpp
+++ b/src/profiling/SendCounterPacket.hpp
@@ -6,9 +6,10 @@
#pragma once
#include "IBufferManager.hpp"
-#include "ISendCounterPacket.hpp"
#include "ICounterDirectory.hpp"
+#include "ISendCounterPacket.hpp"
#include "IProfilingConnection.hpp"
+#include "ProfilingStateMachine.hpp"
#include "ProfilingUtils.hpp"
#include <atomic>
@@ -26,20 +27,25 @@ namespace profiling
class SendCounterPacket : public ISendCounterPacket
{
public:
- using CategoryRecord = std::vector<uint32_t>;
- using DeviceRecord = std::vector<uint32_t>;
- using CounterSetRecord = std::vector<uint32_t>;
- using EventRecord = std::vector<uint32_t>;
-
+ using CategoryRecord = std::vector<uint32_t>;
+ using DeviceRecord = std::vector<uint32_t>;
+ using CounterSetRecord = std::vector<uint32_t>;
+ using EventRecord = std::vector<uint32_t>;
using IndexValuePairsVector = std::vector<std::pair<uint16_t, uint32_t>>;
- SendCounterPacket(IBufferManager& buffer, int timeout = 1000)
- : m_BufferManager(buffer)
+ SendCounterPacket(ProfilingStateMachine& profilingStateMachine, IBufferManager& buffer, int timeout = 1000)
+ : m_StateMachine(profilingStateMachine)
+ , m_BufferManager(buffer)
, m_Timeout(timeout)
, m_IsRunning(false)
, m_KeepRunning(false)
+ , m_SendThreadException(nullptr)
{}
- ~SendCounterPacket() { Stop(); }
+ ~SendCounterPacket()
+ {
+ // Don't rethrow when destructing the object
+ Stop(false);
+ }
void SendStreamMetaDataPacket() override;
@@ -56,7 +62,7 @@ public:
static const unsigned int MAX_METADATA_PACKET_LENGTH = 4096;
void Start(IProfilingConnection& profilingConnection);
- void Stop();
+ void Stop(bool rethrowSendThreadExceptions = true);
bool IsRunning() { return m_IsRunning.load(); }
private:
@@ -76,6 +82,7 @@ private:
{
SetReadyToRead();
}
+
if (writerBuffer != nullptr)
{
// Cancel the operation
@@ -88,6 +95,7 @@ private:
void FlushBuffer(IProfilingConnection& profilingConnection);
+ ProfilingStateMachine& m_StateMachine;
IBufferManager& m_BufferManager;
int m_Timeout;
std::mutex m_WaitMutex;
@@ -95,6 +103,7 @@ private:
std::thread m_SendThread;
std::atomic<bool> m_IsRunning;
std::atomic<bool> m_KeepRunning;
+ std::exception_ptr m_SendThreadException;
protected:
// Helper methods, protected for testing