aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/SendCounterPacket.cpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-07 10:19:35 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-07 16:04:07 +0100
commite61ffd00a37f02338129e92d65be2f01600014c0 (patch)
tree415a475edeae4e7487b512ce78315228819bab87 /src/profiling/SendCounterPacket.cpp
parentf21f606ac60fca82a320de6a706e69d84d3c895c (diff)
downloadarmnn-e61ffd00a37f02338129e92d65be2f01600014c0.tar.gz
IVGCVSW-3937 Make dynamic use the of the profiling connection
in the SendCounterPacket class * Passing the profiling connection as an argument to the pertinent methods of the SendCounterPacket class, as the connection is created dynamically by the ProfilingService * Updated the unit tests accordingly Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: Ibe72bdbad814a201c4f1505cff4badbb9b03b13e
Diffstat (limited to 'src/profiling/SendCounterPacket.cpp')
-rw-r--r--src/profiling/SendCounterPacket.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp
index 813cccfe6a..dc5a950bea 100644
--- a/src/profiling/SendCounterPacket.cpp
+++ b/src/profiling/SendCounterPacket.cpp
@@ -901,7 +901,7 @@ void SendCounterPacket::SetReadyToRead()
m_WaitCondition.notify_one();
}
-void SendCounterPacket::Start()
+void SendCounterPacket::Start(IProfilingConnection& profilingConnection)
{
// Check if the send thread is already running
if (m_IsRunning.load())
@@ -917,7 +917,7 @@ void SendCounterPacket::Start()
m_KeepRunning.store(true);
// Start the send thread
- m_SendThread = std::thread(&SendCounterPacket::Send, this);
+ m_SendThread = std::thread(&SendCounterPacket::Send, this, std::ref(profilingConnection));
}
void SendCounterPacket::Stop()
@@ -936,7 +936,7 @@ void SendCounterPacket::Stop()
}
}
-void SendCounterPacket::Send()
+void SendCounterPacket::Send(IProfilingConnection& profilingConnection)
{
// Keep the sending procedure looping until the thread is signalled to stop
while (m_KeepRunning.load())
@@ -954,23 +954,23 @@ void SendCounterPacket::Send()
else
{
// Wait until the thread is notified of something to read from the buffer,
- // or check anyway after a second
- m_WaitCondition.wait_for(lock, std::chrono::seconds(m_Timeout));
+ // or check anyway after the specified number of milliseconds
+ m_WaitCondition.wait_for(lock, std::chrono::milliseconds(m_Timeout));
}
}
// Wait condition lock scope - End
- FlushBuffer();
+ FlushBuffer(profilingConnection);
}
// Ensure that all readable data got written to the profiling connection before the thread is stopped
- FlushBuffer();
+ FlushBuffer(profilingConnection);
// Mark the send thread as not running
m_IsRunning.store(false);
}
-void SendCounterPacket::FlushBuffer()
+void SendCounterPacket::FlushBuffer(IProfilingConnection& profilingConnection)
{
// Get the first available readable buffer
std::unique_ptr<IPacketBuffer> packetBuffer = m_BufferManager.GetReadableBuffer();
@@ -991,10 +991,10 @@ void SendCounterPacket::FlushBuffer()
}
// Check that the profiling connection is open, silently drop the data and continue if it's closed
- if (m_ProfilingConnection.IsOpen())
+ if (profilingConnection.IsOpen())
{
// Write a packet to the profiling connection. Silently ignore any write error and continue
- m_ProfilingConnection.WritePacket(readBuffer, boost::numeric_cast<uint32_t>(readBufferSize));
+ profilingConnection.WritePacket(readBuffer, boost::numeric_cast<uint32_t>(readBufferSize));
}
// Mark the packet buffer as read