IVGCVSW-3937 Refactor the command thread

 * Integrated the Join method into Stop
 * Updated the unit tests accordingly
 * General code refactoring

Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Change-Id: If8537e77b3d3ff2b780f58a07df01191a91d83d2
diff --git a/src/profiling/CommandThread.hpp b/src/profiling/CommandThread.hpp
index 6237cd2..0456ba4 100644
--- a/src/profiling/CommandThread.hpp
+++ b/src/profiling/CommandThread.hpp
@@ -26,19 +26,31 @@
                   bool stopAfterTimeout,
                   CommandHandlerRegistry& commandHandlerRegistry,
                   PacketVersionResolver& packetVersionResolver,
-                  IProfilingConnection& socketProfilingConnection);
+                  IProfilingConnection& socketProfilingConnection)
+        : m_Timeout(timeout)
+        , m_StopAfterTimeout(stopAfterTimeout)
+        , m_IsRunning(false)
+        , m_KeepRunning(false)
+        , m_CommandThread()
+        , m_CommandHandlerRegistry(commandHandlerRegistry)
+        , m_PacketVersionResolver(packetVersionResolver)
+        , m_SocketProfilingConnection(socketProfilingConnection)
+    {}
+    ~CommandThread() { Stop(); }
 
     void Start();
     void Stop();
-    void Join();
+
     bool IsRunning() const;
-    bool StopAfterTimeout(bool StopAfterTimeout);
+
+    void SetTimeout(uint32_t timeout);
+    void SetStopAfterTimeout(bool stopAfterTimeout);
 
 private:
     void WaitForPacket();
 
-    uint32_t m_Timeout;
-    bool m_StopAfterTimeout;
+    std::atomic<uint32_t> m_Timeout;
+    std::atomic<bool> m_StopAfterTimeout;
     std::atomic<bool> m_IsRunning;
     std::atomic<bool> m_KeepRunning;
     std::thread m_CommandThread;
@@ -48,6 +60,6 @@
     IProfilingConnection& m_SocketProfilingConnection;
 };
 
-}//namespace profiling
+} // namespace profiling
 
-}//namespace armnn
\ No newline at end of file
+} // namespace armnn