mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 08:40:30 +08:00
perf(uORB): check for new data before reading the clock in updated()
Assisted-by: Claude:claude-fable-5-1
This commit is contained in:
1 parent
7bfc32e4de
commit
2a9be29e3c
4 files changed
+143
-7
No files matched your search
@@ -45,13 +45,9 @@ namespace uORB
|
||||
template <bool ATOMIC>
|
||||
bool SubscriptionIntervalBase<ATOMIC>::updated()
|
||||
{
|
||||
hrt_abstime last_update = _last_update.load();
|
||||
|
||||
if (advertised() && (hrt_elapsed_time(&last_update) >= _interval_us.load())) {
|
||||
return _subscription.updated();
|
||||
}
|
||||
|
||||
return false;
|
||||
// New data implies advertised(); checking it first keeps the clock read off
|
||||
// the common no-update path.
|
||||
return _subscription.updated() && interval_elapsed();
|
||||
}
|
||||
|
||||
template <bool ATOMIC>
|
||||
|
||||
Reference in new issue
Block a user