mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-29 07:34:06 +08:00
uORBDeviceNode: move flags from SubscriberData to UpdateIntervalData
As there is only one bit used in 'flags', and it is only used in case update_interval is not null, we can move the bit to UpdateIntervalData. The size of UpdateIntervalData does not increase (on 32 bit). Reduces RAM usage by 3.6KB (tested on a Pixracer).
This commit is contained in:
parent
90cee2d5ea
commit
e91db7b4d2
@ -184,21 +184,23 @@ protected:
|
||||
|
||||
private:
|
||||
struct UpdateIntervalData {
|
||||
unsigned interval; /**< if nonzero minimum interval between updates */
|
||||
struct hrt_call update_call; /**< deferred wakeup call if update_period is nonzero */
|
||||
#ifndef __PX4_NUTTX
|
||||
uint64_t last_update; /**< time at which the last update was provided, used when update_interval is nonzero */
|
||||
#endif
|
||||
unsigned interval; /**< if nonzero minimum interval between updates */
|
||||
bool update_reported;
|
||||
};
|
||||
struct SubscriberData {
|
||||
~SubscriberData() { if (update_interval) { delete (update_interval); } }
|
||||
|
||||
unsigned generation; /**< last generation the subscriber has seen */
|
||||
int flags; /**< lowest 8 bits: priority of publisher, 9. bit: update_reported bit */
|
||||
UpdateIntervalData *update_interval; /**< if null, no update interval */
|
||||
|
||||
bool update_reported() const { return flags & (1 << 8); }
|
||||
void set_update_reported(bool update_reported_flag) { flags = (flags & ~(1 << 8)) | (((int)update_reported_flag) << 8); }
|
||||
// these flags are only used if update_interval != null
|
||||
bool update_reported() const { return update_interval ? update_interval->update_reported : false; }
|
||||
void set_update_reported(bool update_reported_flag)
|
||||
{ if (update_interval) { update_interval->update_reported = update_reported_flag; } }
|
||||
};
|
||||
|
||||
const struct orb_metadata *_meta; /**< object metadata information */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user