prevent future refactoring errors

This commit is contained in:
J. Nick Koston 2025-07-06 19:27:33 -05:00
parent add7bec7f2
commit b12d7db5a7
No known key found for this signature in database

View File

@ -99,9 +99,15 @@ class Scheduler {
SchedulerItem(const SchedulerItem &) = delete; SchedulerItem(const SchedulerItem &) = delete;
SchedulerItem &operator=(const SchedulerItem &) = delete; SchedulerItem &operator=(const SchedulerItem &) = delete;
// Default move operations // Delete move operations to prevent accidental moves of SchedulerItem objects.
SchedulerItem(SchedulerItem &&) = default; // This is intentional because:
SchedulerItem &operator=(SchedulerItem &&) = default; // 1. SchedulerItem contains a dynamically allocated name that requires careful ownership management
// 2. The scheduler only moves unique_ptr<SchedulerItem>, never SchedulerItem objects directly
// 3. Moving unique_ptr only transfers pointer ownership without moving the pointed-to object
// 4. Deleting these operations makes it explicit that SchedulerItem objects should not be moved
// 5. This prevents potential double-free bugs if the code is refactored to move SchedulerItem objects
SchedulerItem(SchedulerItem &&) = delete;
SchedulerItem &operator=(SchedulerItem &&) = delete;
// Helper to get the name regardless of storage type // Helper to get the name regardless of storage type
const char *get_name() const { return name_is_dynamic ? name_.dynamic_name : name_.static_name; } const char *get_name() const { return name_is_dynamic ? name_.dynamic_name : name_.static_name; }