Skip to content

Commit 7f4e119

Browse files
bmehta001Copilot
andcommitted
Make m_scheduledUploadTime atomic for explicit thread safety
Declare m_scheduledUploadTime as std::atomic<uint64_t> and move its update back outside the LOCKGUARD, consistent with m_runningLatency. All accesses were already under LOCKGUARD(m_scheduledUploadMutex), but atomic makes the thread-safe intent self-documenting and guards against future accesses that might omit the lock. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 710a531 commit 7f4e119

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/tpm/TransmissionPolicyManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ namespace MAT_NS_BEGIN {
185185
return;
186186
}
187187
m_runningLatency = latency;
188+
m_scheduledUploadTime = std::numeric_limits<uint64_t>::max();
188189
{
189190
LOCKGUARD(m_scheduledUploadMutex);
190-
m_scheduledUploadTime = std::numeric_limits<uint64_t>::max();
191191
m_isUploadScheduled = false; // Allow to schedule another uploadAsync
192192
if ((m_isPaused) || (m_scheduledUploadAborted))
193193
{

lib/tpm/TransmissionPolicyManager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ constexpr const char* const DefaultBackoffConfig = "E,3000,300000,2,1";
9191

9292
std::atomic<bool> m_isPaused { true };
9393
std::atomic<bool> m_isUploadScheduled { false };
94-
uint64_t m_scheduledUploadTime { std::numeric_limits<uint64_t>::max() };
94+
std::atomic<uint64_t> m_scheduledUploadTime { std::numeric_limits<uint64_t>::max() };
9595
std::mutex m_scheduledUploadMutex;
9696
PAL::DeferredCallbackHandle m_scheduledUpload;
9797
bool m_scheduledUploadAborted { false };

0 commit comments

Comments
 (0)