Snapshot the update mode and update LEDs flag at the same time in the RGBController background thread to prevent executing them out of order

This commit is contained in:
Adam Honse committed 2026-10-15 11:32:18 -05:00
1 parent 46bfeb026f
commit 6c8a6a9125
1 file changed
+11 -2
+11 -2
View File
@@ -2059,7 +2059,16 @@ void RGBController::DeviceCallThreadFunction()
while(DeviceThreadRunning.load() == true)
{
if(CallFlag_UpdateMode.load() == true)
/*-------------------------------------------------*\
| Snapshot both flags at the same time to prevent |
| scenario where an UpdateMode->UpdateLEDs sequence |
| is inadvertently executed out of order, which can |
| lead to the LED color being dropped. |
\*-------------------------------------------------*/
bool update_mode = CallFlag_UpdateMode.load();
bool update_leds = CallFlag_UpdateLEDs.load();
if(update_mode == true)
{
if(flags & CONTROLLER_FLAG_RESET_BEFORE_UPDATE)
{
@@ -2080,7 +2089,7 @@ void RGBController::DeviceCallThreadFunction()
AccessMutex.unlock_shared();
}
}
if(CallFlag_UpdateLEDs.load() == true)
if(update_leds == true)
{
if(flags & CONTROLLER_FLAG_RESET_BEFORE_UPDATE)
{