mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-09-24 19:08:21 +08:00
refactor(px4_work_queue): out-line ScheduledWorkItem ctor and ScheduleNow (#28440)
* refactor(px4_work_queue): out-line ScheduledWorkItem constructor to save flash The header-inline constructor zero-initialises the hrt_call member at every derived work-item constructor across ~150 classes. Move the definition (verbatim) into ScheduledWorkItem.cpp next to the destructor; the derived constructors already pay a call into the base constructor chain, so this only removes the duplicated inline stores. Saves 1376 B of .text on px4_fmu-v6x_default. Signed-off-by: Balduin <balduin@auterion.com> * refactor(px4_work_queue): out-line WorkItem::ScheduleNow to save flash The body was inlined at ~240 call sites; a plain call is smaller at every one of them. Saves 672 B FLASH on px4_fmu-v6x_default. Signed-off-by: Balduin <balduin@auterion.com> --------- Signed-off-by: Balduin <balduin@auterion.com> Co-authored-by: Balduin <balduin@auterion.com>
This commit is contained in:
@@ -77,7 +77,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
ScheduledWorkItem(const char *name, const wq_config_t &config) : WorkItem(name, config) {}
|
||||
ScheduledWorkItem(const char *name, const wq_config_t &config);
|
||||
|
||||
virtual void print_run_status() override;
|
||||
|
||||
|
||||
@@ -64,12 +64,7 @@ public:
|
||||
// WorkItems sorted by name
|
||||
bool operator<=(const WorkItem &rhs) const { return (strcmp(ItemName(), rhs.ItemName()) <= 0); }
|
||||
|
||||
inline void ScheduleNow()
|
||||
{
|
||||
if (_wq != nullptr) {
|
||||
_wq->Add(this);
|
||||
}
|
||||
}
|
||||
void ScheduleNow();
|
||||
|
||||
virtual void print_run_status();
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
namespace px4
|
||||
{
|
||||
|
||||
ScheduledWorkItem::ScheduledWorkItem(const char *name, const wq_config_t &config) : WorkItem(name, config) {}
|
||||
|
||||
ScheduledWorkItem::~ScheduledWorkItem()
|
||||
{
|
||||
if (_call.arg != nullptr) {
|
||||
|
||||
@@ -116,6 +116,13 @@ void WorkItem::Deinit()
|
||||
}
|
||||
}
|
||||
|
||||
void WorkItem::ScheduleNow()
|
||||
{
|
||||
if (_wq != nullptr) {
|
||||
_wq->Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
void WorkItem::ScheduleClear()
|
||||
{
|
||||
if (_wq != nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user