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 --- .../classarmnn_1_1profiling_1_1_send_thread.xhtml | 396 +++++++++++++++++++++ 1 file changed, 396 insertions(+) create mode 100644 20.02/classarmnn_1_1profiling_1_1_send_thread.xhtml (limited to '20.02/classarmnn_1_1profiling_1_1_send_thread.xhtml') diff --git a/20.02/classarmnn_1_1profiling_1_1_send_thread.xhtml b/20.02/classarmnn_1_1profiling_1_1_send_thread.xhtml new file mode 100644 index 0000000000..514f242ae7 --- /dev/null +++ b/20.02/classarmnn_1_1profiling_1_1_send_thread.xhtml @@ -0,0 +1,396 @@ + + + + + + + + + + + + + +ArmNN: SendThread Class Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.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 27 of file SendThread.cpp.

+ +

References IBufferManager::SetConsumer().

+
29  : m_StateMachine(profilingStateMachine)
30  , m_BufferManager(buffer)
31  , m_SendCounterPacket(sendCounterPacket)
32  , m_Timeout(timeout)
33  , m_IsRunning(false)
34  , m_KeepRunning(false)
35  , m_SendThreadException(nullptr)
36 {
37  m_BufferManager.SetConsumer(this);
38 }
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:81
+
+
+
+

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 40 of file SendThread.cpp.

+ +

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

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

◆ Start()

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

Start the thread.

+ +

Implements ISendThread.

+ +

Definition at line 51 of file SendThread.cpp.

+ +

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

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

◆ Stop()

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

Stop the thread.

+ +

Implements ISendThread.

+ +

Definition at line 81 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().

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

◆ WaitForPacketSent()

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

Definition at line 262 of file SendThread.cpp.

+ +

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

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