fix: properly implement requestUpdateAndWait() (#1218)

## Summary

Properly implement `requestUpdateAndWait()` using freeRTOS direct task
notification.

FWIW, I think most of the current use cases of `requestUpdateAndWait()`
are redundant, better to be replaced by `requestUpdate(true)`. But just
keeping them in case we can find a proper use case for it in the future.

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? **YES**, it's trivial, so
I asked an AI to write the code

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Xuan-Son Nguyen
2026-03-01 02:12:57 +01:00
committed by GitHub
parent 3da2cd3cf8
commit a57c62f0b4
4 changed files with 49 additions and 6 deletions

View File

@@ -50,6 +50,10 @@ class ActivityManager {
static void renderTaskTrampoline(void* param);
[[noreturn]] virtual void renderTaskLoop();
// Set by requestUpdateAndWait(); read and cleared by the render task after render completes.
// Note: only one waiting task is supported at a time
TaskHandle_t waitingTaskHandle = nullptr;
// Mutex to protect rendering operations from race conditions
// Must only be used via RenderLock
SemaphoreHandle_t renderingMutex = nullptr;
@@ -98,6 +102,10 @@ class ActivityManager {
// If immediate is true, the update will be triggered immediately.
// Otherwise, it will be deferred until the end of the current loop iteration.
void requestUpdate(bool immediate = false);
// Trigger a render and block until it completes.
// Must NOT be called from the render task or while holding a RenderLock.
void requestUpdateAndWait();
};
extern ActivityManager activityManager; // singleton, to be defined in main.cpp