blob: 0456ba43720325c7ec23f29b73e536cfa03c5217 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
//
// Copyright © 2019 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include "CommandHandlerRegistry.hpp"
#include "IProfilingConnection.hpp"
#include "PacketVersionResolver.hpp"
#include "ProfilingService.hpp"
#include <atomic>
#include <thread>
namespace armnn
{
namespace profiling
{
class CommandThread
{
public:
CommandThread(uint32_t timeout,
bool stopAfterTimeout,
CommandHandlerRegistry& commandHandlerRegistry,
PacketVersionResolver& packetVersionResolver,
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();
bool IsRunning() const;
void SetTimeout(uint32_t timeout);
void SetStopAfterTimeout(bool stopAfterTimeout);
private:
void WaitForPacket();
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;
CommandHandlerRegistry& m_CommandHandlerRegistry;
PacketVersionResolver& m_PacketVersionResolver;
IProfilingConnection& m_SocketProfilingConnection;
};
} // namespace profiling
} // namespace armnn
|