From fd627ffaec8fd8801d980b4c91ee7c0607ab6aaf Mon Sep 17 00:00:00 2001 From: Jan Eilers Date: Thu, 25 Feb 2021 17:44:00 +0000 Subject: IVGCVSW-5687 Update Doxygen Docu * Update Doxygen Documentation for 21.02 release Signed-off-by: Jan Eilers Change-Id: I9ed2f9caab038836ea99d7b378d7899fe431a4e5 --- .../classarmnn_1_1profiling_1_1_send_thread.xhtml | 396 +++++++++++++++++++++ 1 file changed, 396 insertions(+) create mode 100644 21.02/classarmnn_1_1profiling_1_1_send_thread.xhtml (limited to '21.02/classarmnn_1_1profiling_1_1_send_thread.xhtml') diff --git a/21.02/classarmnn_1_1profiling_1_1_send_thread.xhtml b/21.02/classarmnn_1_1profiling_1_1_send_thread.xhtml new file mode 100644 index 0000000000..f333b1217a --- /dev/null +++ b/21.02/classarmnn_1_1profiling_1_1_send_thread.xhtml @@ -0,0 +1,396 @@ + + + + + + + + + + + + + +ArmNN: SendThread Class Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  21.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
SendThread Class Reference
+
+
+ +

#include <SendThread.hpp>

+
+Inheritance diagram for SendThread:
+
+
+ + +ISendThread +IConsumer + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +

+Public Member Functions

 SendThread (ProfilingStateMachine &profilingStateMachine, IBufferManager &buffer, ISendCounterPacket &sendCounterPacket, int timeout=1000)
 
 ~SendThread ()
 
void Start (IProfilingConnection &profilingConnection) override
 Start the thread. More...
 
void Stop (bool rethrowSendThreadExceptions=true) override
 Stop the thread. More...
 
void SetReadyToRead () override
 Set a "ready to read" flag in the buffer to notify the reading thread to start reading it. More...
 
bool IsRunning ()
 
bool WaitForPacketSent (uint32_t timeout)
 
- Public Member Functions inherited from ISendThread
virtual ~ISendThread ()
 
- Public Member Functions inherited from IConsumer
virtual ~IConsumer ()
 
+

Detailed Description

+
+

Definition at line 29 of file SendThread.hpp.

+

Constructor & Destructor Documentation

+ +

◆ SendThread()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SendThread (ProfilingStateMachineprofilingStateMachine,
IBufferManagerbuffer,
ISendCounterPacketsendCounterPacket,
int timeout = 1000 
)
+
+ +

Definition at line 23 of file SendThread.cpp.

+ +

References IBufferManager::SetConsumer().

+
27  : m_StateMachine(profilingStateMachine)
28  , m_BufferManager(buffer)
29  , m_SendCounterPacket(sendCounterPacket)
30  , m_Timeout(timeout)
31  , m_IsRunning(false)
32  , m_KeepRunning(false)
33  , m_SendThreadException(nullptr)
34 {
35  m_BufferManager.SetConsumer(this);
36 }
virtual void SetConsumer(IConsumer *consumer)=0
+
+
+
+ +

◆ ~SendThread()

+ +
+
+ + + + + +
+ + + + + + + +
~SendThread ()
+
+inline
+
+ +

Definition at line 34 of file SendThread.hpp.

+ +

References SendThread::SetReadyToRead(), SendThread::Start(), and SendThread::Stop().

+
35  {
36  // Don't rethrow when destructing the object
37  Stop(false);
38  }
void Stop(bool rethrowSendThreadExceptions=true) override
Stop the thread.
Definition: SendThread.cpp:79
+
+
+
+

Member Function Documentation

+ +

◆ IsRunning()

+ +
+
+ + + + + +
+ + + + + + + +
bool IsRunning ()
+
+inline
+
+ +

Definition at line 45 of file SendThread.hpp.

+ +

References SendThread::WaitForPacketSent().

+ +

Referenced by BOOST_AUTO_TEST_CASE().

+
45 { return m_IsRunning.load(); }
+
+
+ +

◆ SetReadyToRead()

+ +
+
+ + + + + +
+ + + + + + + +
void SetReadyToRead ()
+
+overridevirtual
+
+ +

Set a "ready to read" flag in the buffer to notify the reading thread to start reading it.

+ +

Implements IConsumer.

+ +

Definition at line 38 of file SendThread.cpp.

+ +

Referenced by BOOST_AUTO_TEST_CASE(), SendThread::Stop(), and SendThread::~SendThread().

+
39 {
40  // We need to wait for the send thread to release its mutex
41  {
42  std::lock_guard<std::mutex> lck(m_WaitMutex);
43  m_ReadyToRead = true;
44  }
45  // Signal the send thread that there's something to read in the buffer
46  m_WaitCondition.notify_one();
47 }
+
+
+ +

◆ Start()

+ +
+
+ + + + + +
+ + + + + + + + +
void Start (IProfilingConnectionprofilingConnection)
+
+overridevirtual
+
+ +

Start the thread.

+ +

Implements ISendThread.

+ +

Definition at line 49 of file SendThread.cpp.

+ +

Referenced by BOOST_AUTO_TEST_CASE(), ProfilingService::Update(), and SendThread::~SendThread().

+
50 {
51  // Check if the send thread is already running
52  if (m_IsRunning.load())
53  {
54  // The send thread is already running
55  return;
56  }
57 
58  if (m_SendThread.joinable())
59  {
60  m_SendThread.join();
61  }
62 
63  // Mark the send thread as running
64  m_IsRunning.store(true);
65 
66  // Keep the send procedure going until the send thread is signalled to stop
67  m_KeepRunning.store(true);
68 
69  // Make sure the send thread will not flush the buffer until signaled to do so
70  // no need for a mutex as the send thread can not be running at this point
71  m_ReadyToRead = false;
72 
73  m_PacketSent = false;
74 
75  // Start the send thread
76  m_SendThread = std::thread(&SendThread::Send, this, std::ref(profilingConnection));
77 }
+
+
+ +

◆ Stop()

+ +
+
+ + + + + +
+ + + + + + + + +
void Stop (bool rethrowSendThreadExceptions = true)
+
+overridevirtual
+
+ +

Stop the thread.

+ +

Implements ISendThread.

+ +

Definition at line 79 of file SendThread.cpp.

+ +

References armnn::profiling::Active, ProfilingStateMachine::GetCurrentState(), IBufferManager::GetReadableBuffer(), IProfilingConnection::IsOpen(), IBufferManager::MarkRead(), armnn::profiling::NotConnected, ISendCounterPacket::SendStreamMetaDataPacket(), SendThread::SetReadyToRead(), armnn::profiling::Uninitialised, armnn::profiling::WaitingForAck, and IProfilingConnection::WritePacket().

+ +

Referenced by BOOST_AUTO_TEST_CASE(), ProfilingService::GetSendTimelinePacket(), ProfilingService::Update(), and SendThread::~SendThread().

+
80 {
81  // Signal the send thread to stop
82  m_KeepRunning.store(false);
83 
84  // Check that the send thread is running
85  if (m_SendThread.joinable())
86  {
87  // Kick the send thread out of the wait condition
89  // Wait for the send thread to complete operations
90  m_SendThread.join();
91  }
92 
93  // Check if the send thread exception has to be rethrown
94  if (!rethrowSendThreadExceptions)
95  {
96  // No need to rethrow the send thread exception, return immediately
97  return;
98  }
99 
100  // Check if there's an exception to rethrow
101  if (m_SendThreadException)
102  {
103  // Rethrow the send thread exception
104  std::rethrow_exception(m_SendThreadException);
105 
106  // Nullify the exception as it has been rethrown
107  m_SendThreadException = nullptr;
108  }
109 }
void SetReadyToRead() override
Set a "ready to read" flag in the buffer to notify the reading thread to start reading it...
Definition: SendThread.cpp:38
+
+
+
+ +

◆ WaitForPacketSent()

+ +
+
+ + + + + + + + +
bool WaitForPacketSent (uint32_t timeout = 1000)
+
+ +

Definition at line 260 of file SendThread.cpp.

+ +

Referenced by SendThread::IsRunning(), and ProfilingService::WaitForPacketSent().

+
261 {
262  std::unique_lock<std::mutex> lock(m_PacketSentWaitMutex);
263  // Blocks until notified that at least a packet has been sent or until timeout expires.
264  bool timedOut = m_PacketSentWaitCondition.wait_for(lock,
265  std::chrono::milliseconds(timeout),
266  [&] { return m_PacketSent; });
267 
268  m_PacketSent = false;
269 
270  return timedOut;
271 }
+
+
+
The documentation for this class was generated from the following files: +
+
+ + + + -- cgit v1.2.1