blob: 6237cd29142ed32a8fcbb65bf56a82d212b9979f [file] [log] [blame]
FinnWilliamsArm4833cea2019-09-17 16:53:53 +01001//
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
16namespace armnn
17{
18
19namespace profiling
20{
21
22class CommandThread
23{
24public:
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
37private:
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