perf(uORB): load _last_update in callbacks only when an interval is set

Assisted-by: Claude:claude-fable-5-1
This commit is contained in:
Lourens Naude authored and Beat Küng committed 2026-10-22 08:26:26 +02:00
1 parent 2a9be29e3c
commit 427bf69cdd
2 files changed
+4 -12

No files matched your search

@@ -67,10 +67,7 @@ public:
void call(unsigned generation) override
{
// signal immediately if no interval, otherwise only if interval has elapsed
hrt_abstime last_update = _last_update.load();
const uint32_t interval_us = _interval_us.load();
if ((interval_us == 0) || (hrt_elapsed_time(&last_update) >= interval_us)) {
if (interval_elapsed()) {
pthread_cond_signal(&_cv);
}
}
@@ -149,14 +149,9 @@ public:
// (count gate), respecting the optional interval (interval gate).
const uint8_t req = _required_updates.load();
if ((generation - _last_scheduled_generation) >= req) {
const hrt_abstime last_update = _last_update.load();
const uint32_t interval_us = _interval_us.load();
if ((interval_us == 0) || (hrt_elapsed_time(&last_update) >= interval_us)) {
_last_scheduled_generation = generation;
_work_item->ScheduleNow();
}
if (((generation - _last_scheduled_generation) >= req) && interval_elapsed()) {
_last_scheduled_generation = generation;
_work_item->ScheduleNow();
}
}