From 24e8f9209249c9d41e57748a1b9d2f5f978db4ee Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Thu, 19 Sep 2019 11:57:46 +0100 Subject: IVGCVSW-3905 Create a first implementation of the send thread * Added the send thread directly to the SendCounterPacket class * Updated the SendCounterPacket class constructor to also take a reference of a IProfilingConnection object, used to send packets out * Added Start and Stop methods to SendCounterPacket to start and stop the send thread * Added mutex and wait condition to make the send thread waiting for something to send * This implementation used the old IBufferWrapper interface * Added defult (empty) constructor for the Packet class * Refactoring of IPeriodicCounterCapture and SocketProfilingConnection * Modified WritePacket to make it match IBufferWrapper::GetReadBuffer * Added unit test for regular and stress testing of the send thread Signed-off-by: Matteo Martincigh Change-Id: I8175619ff4e65c0d5be99bcd8bd9d8dd87f717c6 --- src/profiling/Packet.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/profiling/Packet.hpp') diff --git a/src/profiling/Packet.hpp b/src/profiling/Packet.hpp index 1e047a6511..7d70a48366 100644 --- a/src/profiling/Packet.hpp +++ b/src/profiling/Packet.hpp @@ -17,8 +17,16 @@ namespace profiling class Packet { public: + Packet() + : m_Header(0) + , m_Length(0) + , m_Data(nullptr) + {} + Packet(uint32_t header, uint32_t length, std::unique_ptr& data) - : m_Header(header), m_Length(length), m_Data(std::move(data)) + : m_Header(header) + , m_Length(length) + , m_Data(std::move(data)) { m_PacketId = ((header >> 16) & 1023); m_PacketFamily = (header >> 26); @@ -34,7 +42,8 @@ public: m_PacketFamily(other.m_PacketFamily), m_PacketId(other.m_PacketId), m_Length(other.m_Length), - m_Data(std::move(other.m_Data)){}; + m_Data(std::move(other.m_Data)) + {} Packet(const Packet& other) = delete; Packet& operator=(const Packet&) = delete; @@ -48,6 +57,8 @@ public: uint32_t GetPacketClass() const; uint32_t GetPacketType() const; + bool IsEmpty() { return m_Header == 0 && m_Length == 0; } + private: uint32_t m_Header; uint32_t m_PacketFamily; -- cgit v1.2.1