aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/SendCounterPacket.cpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-10 14:08:21 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-11 16:33:29 +0100
commite848538efbdf01aa0b067da942c3c214f8e62826 (patch)
treed700239f1316a098849fcfc39ec70e926f86fd62 /src/profiling/SendCounterPacket.cpp
parentf982deaefbe5fe5814487b27f7099829839b8666 (diff)
downloadarmnn-e848538efbdf01aa0b067da942c3c214f8e62826.tar.gz
IVGCVSW-3964 Implement the Periodic Counter Selection command handler
* Improved the PeriodicCounterPacket class to handle errors properly * Improved the PeriodicCounterSelectionCommandHandler to handle invalid counter UIDs in the selection packet * Added the Periodic Counter Selection command handler to the ProfilingService class * Code refactoring and added comments * Added WaitForPacketSent method to the SendCounterPacket class to allow waiting for the packets to be sent (useful in the unit tests) * Added unit tests and updated the old ones accordingly * Fixed threading issues with a number of unit tests Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I271b7b0bfa801d88fe1725b934d24e30cd839ed7
Diffstat (limited to 'src/profiling/SendCounterPacket.cpp')
-rw-r--r--src/profiling/SendCounterPacket.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp
index e48da3ed7c..41adf37244 100644
--- a/src/profiling/SendCounterPacket.cpp
+++ b/src/profiling/SendCounterPacket.cpp
@@ -1035,17 +1035,21 @@ void SendCounterPacket::Send(IProfilingConnection& profilingConnection)
}
// Ensure that all readable data got written to the profiling connection before the thread is stopped
- FlushBuffer(profilingConnection);
+ // (do not notify any watcher in this case, as this is just to wrap up things before shutting down the send thread)
+ FlushBuffer(profilingConnection, false);
// Mark the send thread as not running
m_IsRunning.store(false);
}
-void SendCounterPacket::FlushBuffer(IProfilingConnection& profilingConnection)
+void SendCounterPacket::FlushBuffer(IProfilingConnection& profilingConnection, bool notifyWatchers)
{
// Get the first available readable buffer
std::unique_ptr<IPacketBuffer> packetBuffer = m_BufferManager.GetReadableBuffer();
+ // Initialize the flag that indicates whether at least a packet has been sent
+ bool packetsSent = false;
+
while (packetBuffer != nullptr)
{
// Get the data to send from the buffer
@@ -1066,6 +1070,9 @@ void SendCounterPacket::FlushBuffer(IProfilingConnection& profilingConnection)
{
// Write a packet to the profiling connection. Silently ignore any write error and continue
profilingConnection.WritePacket(readBuffer, boost::numeric_cast<uint32_t>(readBufferSize));
+
+ // Set the flag that indicates whether at least a packet has been sent
+ packetsSent = true;
}
// Mark the packet buffer as read
@@ -1074,6 +1081,13 @@ void SendCounterPacket::FlushBuffer(IProfilingConnection& profilingConnection)
// Get the next available readable buffer
packetBuffer = m_BufferManager.GetReadableBuffer();
}
+
+ // Check whether at least a packet has been sent
+ if (packetsSent && notifyWatchers)
+ {
+ // Notify to any watcher that something has been sent
+ m_PacketSentWaitCondition.notify_one();
+ }
}
} // namespace profiling