From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- 20.02/_command_handler_8cpp_source.xhtml | 137 +++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 20.02/_command_handler_8cpp_source.xhtml (limited to '20.02/_command_handler_8cpp_source.xhtml') diff --git a/20.02/_command_handler_8cpp_source.xhtml b/20.02/_command_handler_8cpp_source.xhtml new file mode 100644 index 0000000000..a80ef57ccc --- /dev/null +++ b/20.02/_command_handler_8cpp_source.xhtml @@ -0,0 +1,137 @@ + + + + + + + + + + + + + +ArmNN: src/profiling/CommandHandler.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
CommandHandler.cpp
+
+
+Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "CommandHandler.hpp"
7 #include "ProfilingService.hpp"
8 
9 #include <armnn/Logging.hpp>
10 
11 namespace armnn
12 {
13 
14 namespace profiling
15 {
16 
17 void CommandHandler::Start(IProfilingConnection& profilingConnection)
18 {
19  if (IsRunning())
20  {
21  return;
22  }
23 
24  if (m_CommandThread.joinable())
25  {
26  m_CommandThread.join();
27  }
28 
29  m_IsRunning.store(true);
30  m_KeepRunning.store(true);
31  m_CommandThread = std::thread(&CommandHandler::HandleCommands, this, std::ref(profilingConnection));
32 }
33 
35 {
36  m_KeepRunning.store(false);
37 
38  if (m_CommandThread.joinable())
39  {
40  m_CommandThread.join();
41  }
42 }
43 
44 void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
45 {
46  do
47  {
48  try
49  {
50  Packet packet = profilingConnection.ReadPacket(m_Timeout.load());
51 
52  if (packet.IsEmpty())
53  {
54  // Nothing to do, continue
55  continue;
56  }
57 
58  Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(),
59  packet.GetPacketId());
60 
61  CommandHandlerFunctor* commandHandlerFunctor =
62  m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(),
63  packet.GetPacketId(),
64  version.GetEncodedValue());
65  BOOST_ASSERT(commandHandlerFunctor);
66  commandHandlerFunctor->operator()(packet);
67  }
68  catch (const armnn::TimeoutException&)
69  {
70  if (m_StopAfterTimeout.load())
71  {
72  m_KeepRunning.store(false);
73  }
74  }
75  catch (const Exception& e)
76  {
77  // Log the error and continue
78  ARMNN_LOG(warning) << "An error has occurred when handling a command: " << e.what();
79  // Did we get here because the socket failed?
80  if ( !profilingConnection.IsOpen() )
81  {
82  // We're going to stop processing commands.
83  // This will leave the thread idle. There is no mechanism to restart the profiling service when the
84  // connection is lost.
85  m_KeepRunning.store(false);
86  }
87  }
88  }
89  while (m_KeepRunning.load());
90 
91  m_IsRunning.store(false);
92 }
93 
94 } // namespace profiling
95 
96 } // namespace armnn
+
void Start(IProfilingConnection &profilingConnection)
+
Version ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const
+
virtual const char * what() const noexcept override
Definition: Exceptions.cpp:32
+
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163
+
CommandHandlerFunctor * GetFunctor(uint32_t familyId, uint32_t packetId, uint32_t version) const
+ +
Copyright (c) 2020 ARM Limited.
+ +
virtual Packet ReadPacket(uint32_t timeout)=0
+ +
uint32_t GetPacketFamily() const
Definition: Packet.hpp:70
+ + + + + + + + +
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
+
uint32_t GetPacketId() const
Definition: Packet.hpp:71
+ + +
+
+ + + + -- cgit v1.2.1