Merge branch 'heap_scheduler_stress_component' into integration

This commit is contained in:
J. Nick Koston 2025-07-06 22:14:38 -05:00
commit bf4cbb0aee
No known key found for this signature in database
2 changed files with 6 additions and 3 deletions

View File

@ -66,7 +66,7 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type
if (delay == SCHEDULER_DONT_RUN) {
// Still need to cancel existing timer if name is not empty
if (name_cstr != nullptr && name_cstr[0] != '\0') {
if (this->is_name_valid_(name_cstr)) {
LockGuard guard{this->lock_};
this->cancel_item_locked_(component, name_cstr, type);
}
@ -125,7 +125,7 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type
LockGuard guard{this->lock_};
// If name is provided, do atomic cancel-and-add
if (name_cstr != nullptr && name_cstr[0] != '\0') {
if (this->is_name_valid_(name_cstr)) {
// Cancel existing items
this->cancel_item_locked_(component, name_cstr, type);
}
@ -443,7 +443,7 @@ bool HOT Scheduler::cancel_item_(Component *component, bool is_static_string, co
const char *name_cstr = this->get_name_cstr_(is_static_string, name_ptr);
// Handle null or empty names
if (name_cstr == nullptr)
if (!this->is_name_valid_(name_cstr))
return false;
// obtain lock because this function iterates and can be called from non-loop task context

View File

@ -150,6 +150,9 @@ class Scheduler {
return is_static_string ? static_cast<const char *>(name_ptr) : static_cast<const std::string *>(name_ptr)->c_str();
}
// Helper to check if a name is valid (not null and not empty)
inline bool is_name_valid_(const char *name) { return name != nullptr && name[0] != '\0'; }
// Common implementation for cancel operations
bool cancel_item_(Component *component, bool is_static_string, const void *name_ptr, SchedulerItem::Type type);