blob: 0cc23429cde9445595c27c19e19e8d36a149eb4b (
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
|
//
// Copyright © 2019 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include "CommandHandlerRegistry.hpp"
#include "IProfilingConnection.hpp"
#include "PacketVersionResolver.hpp"
#include <atomic>
#include <thread>
namespace armnn
{
namespace profiling
{
class CommandHandler
{
public:
CommandHandler(uint32_t timeout,
bool stopAfterTimeout,
CommandHandlerRegistry& commandHandlerRegistry,
PacketVersionResolver& packetVersionResolver)
: m_Timeout(timeout)
, m_StopAfterTimeout(stopAfterTimeout)
, m_IsRunning(false)
, m_KeepRunning(false)
, m_CommandThread()
, m_CommandHandlerRegistry(commandHandlerRegistry)
, m_PacketVersionResolver(packetVersionResolver)
{}
~CommandHandler() { Stop(); }
void SetTimeout(uint32_t timeout) { m_Timeout.store(timeout); }
void SetStopAfterTimeout(bool stopAfterTimeout) { m_StopAfterTimeout.store(stopAfterTimeout); }
void Start(IProfilingConnection& profilingConnection);
void Stop();
bool IsRunning() const { return m_IsRunning.load(); }
private:
void HandleCommands(IProfilingConnection& profilingConnection);
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;
};
} // namespace profiling
} // namespace armnn
|