24 if (m_CommandThread.joinable())
26 m_CommandThread.join();
29 m_IsRunning.store(
true);
30 m_KeepRunning.store(
true);
31 m_CommandThread = std::thread(&CommandHandler::HandleCommands,
this, std::ref(profilingConnection));
36 m_KeepRunning.store(
false);
38 if (m_CommandThread.joinable())
40 m_CommandThread.join();
50 arm::pipe::Packet packet = profilingConnection.
ReadPacket(m_Timeout.load());
58 arm::pipe::Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(),
59 packet.GetPacketId());
61 arm::pipe::CommandHandlerFunctor* commandHandlerFunctor =
62 m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(),
64 version.GetEncodedValue());
66 commandHandlerFunctor->operator()(packet);
70 if (m_StopAfterTimeout.load())
72 m_KeepRunning.store(
false);
75 catch (
const arm::pipe::ProfilingException& e)
78 ARMNN_LOG(
warning) <<
"An error has occurred when handling a command: " << e.what();
80 if ( !profilingConnection.
IsOpen() )
85 m_KeepRunning.store(
false);
93 if ( !profilingConnection.
IsOpen() )
98 m_KeepRunning.store(
false);
102 while (m_KeepRunning.load());
104 m_IsRunning.store(
false);
void Start(IProfilingConnection &profilingConnection)
virtual arm::pipe::Packet ReadPacket(uint32_t timeout)=0
virtual const char * what() const noexcept override
#define ARMNN_LOG(severity)
Copyright (c) 2021 ARM Limited and Contributors.
#define ARMNN_ASSERT(COND)
Base class for all ArmNN exceptions so that users can filter to just those.
virtual bool IsOpen() const =0