FinnWilliamsArm | 4833cea | 2019-09-17 16:53:53 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "CommandHandlerRegistry.hpp" |
| 9 | #include "IProfilingConnection.hpp" |
| 10 | #include "PacketVersionResolver.hpp" |
| 11 | #include "ProfilingService.hpp" |
| 12 | |
| 13 | #include <atomic> |
| 14 | #include <thread> |
| 15 | |
| 16 | namespace armnn |
| 17 | { |
| 18 | |
| 19 | namespace profiling |
| 20 | { |
| 21 | |
| 22 | class CommandThread |
| 23 | { |
| 24 | public: |
| 25 | CommandThread(uint32_t timeout, |
| 26 | bool stopAfterTimeout, |
| 27 | CommandHandlerRegistry& commandHandlerRegistry, |
| 28 | PacketVersionResolver& packetVersionResolver, |
| 29 | IProfilingConnection& socketProfilingConnection); |
| 30 | |
| 31 | void Start(); |
| 32 | void Stop(); |
| 33 | void Join(); |
| 34 | bool IsRunning() const; |
| 35 | bool StopAfterTimeout(bool StopAfterTimeout); |
| 36 | |
| 37 | private: |
| 38 | void WaitForPacket(); |
| 39 | |
| 40 | uint32_t m_Timeout; |
| 41 | bool m_StopAfterTimeout; |
| 42 | std::atomic<bool> m_IsRunning; |
| 43 | std::atomic<bool> m_KeepRunning; |
| 44 | std::thread m_CommandThread; |
| 45 | |
| 46 | CommandHandlerRegistry& m_CommandHandlerRegistry; |
| 47 | PacketVersionResolver& m_PacketVersionResolver; |
| 48 | IProfilingConnection& m_SocketProfilingConnection; |
| 49 | }; |
| 50 | |
| 51 | }//namespace profiling |
| 52 | |
| 53 | }//namespace armnn |