MCPcopy Create free account
hub / github.com/ARM-software/armnn / FlushBuffer

Method FlushBuffer

profiling/client/src/SendThread.cpp:228–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228void SendThread::FlushBuffer(IProfilingConnection& profilingConnection, bool notifyWatchers)
229{
230 // Get the first available readable buffer
231 IPacketBufferPtr packetBuffer = m_BufferManager.GetReadableBuffer();
232
233 // Initialize the flag that indicates whether at least a packet has been sent
234 bool packetsSent = false;
235
236 while (packetBuffer != nullptr)
237 {
238 // Get the data to send from the buffer
239 const unsigned char* readBuffer = packetBuffer->GetReadableData();
240 unsigned int readBufferSize = packetBuffer->GetSize();
241
242 if (readBuffer == nullptr || readBufferSize == 0)
243 {
244 // Nothing to send, get the next available readable buffer and continue
245 m_BufferManager.MarkRead(packetBuffer);
246 packetBuffer = m_BufferManager.GetReadableBuffer();
247
248 continue;
249 }
250
251 // Check that the profiling connection is open, silently drop the data and continue if it's closed
252 if (profilingConnection.IsOpen())
253 {
254 // Write a packet to the profiling connection. Silently ignore any write error and continue
255 profilingConnection.WritePacket(readBuffer, arm::pipe::numeric_cast<uint32_t>(readBufferSize));
256
257 // Set the flag that indicates whether at least a packet has been sent
258 packetsSent = true;
259 }
260
261 // Mark the packet buffer as read
262 m_BufferManager.MarkRead(packetBuffer);
263
264 // Get the next available readable buffer
265 packetBuffer = m_BufferManager.GetReadableBuffer();
266 }
267 // Check whether at least a packet has been sent
268 if (packetsSent && notifyWatchers)
269 {
270 // Wait for the parent thread to release its mutex if necessary
271 {
272#if !defined(ARMNN_DISABLE_THREADS)
273 std::lock_guard<std::mutex> lck(m_PacketSentWaitMutex);
274#endif
275 m_PacketSent = true;
276 }
277 // Notify to any watcher that something has been sent
278#if !defined(ARMNN_DISABLE_THREADS)
279 m_PacketSentWaitCondition.notify_one();
280#endif
281 }
282}
283
284bool SendThread::WaitForPacketSent(uint32_t timeout = 1000)
285{

Callers

nothing calls this directly

Calls 6

GetReadableBufferMethod · 0.45
GetReadableDataMethod · 0.45
GetSizeMethod · 0.45
MarkReadMethod · 0.45
IsOpenMethod · 0.45
WritePacketMethod · 0.45

Tested by

no test coverage detected