aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/CommandThread.hpp
blob: 6237cd29142ed32a8fcbb65bf56a82d212b9979f (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
//
// 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);

    void Start();
    void Stop();
    void Join();
    bool IsRunning() const;
    bool StopAfterTimeout(bool StopAfterTimeout);

private:
    void WaitForPacket();

    uint32_t m_Timeout;
    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