FastLED 3.10.8
Loading...
Searching...
No Matches

◆ update()

void fl::task::Scheduler::update ( )

Definition at line 64 of file scheduler.cpp.hpp.

64 {
65 u32 current_time = fl::millis();
66
67 // Use index-based iteration to avoid iterator invalidation issues
68 for (fl::size i = 0; i < mTasks.size();) {
69 Handle& t = mTasks[i];
70
71 if (!t.is_valid() || t._is_canceled()) {
72 // erase() returns bool in fl::vector, not iterator
73 mTasks.erase(mTasks.begin() + i);
74 // Don't increment i since we just removed an element
75 } else {
76 // Check if task is ready to run (frame tasks will return false here)
77 bool should_run = t._ready_to_run(current_time);
78
79 if (should_run) {
80 // Update last run time for recurring tasks
81 t._set_last_run_time(current_time);
82
83 // Execute the task
84 if (t._has_then()) {
85 t._execute_then();
86 } else {
87 warn_no_then(t._id(), t._trace_label());
88 }
89
90 // Remove one-shot tasks, keep recurring ones
91 bool is_recurring = (t._type() == TaskType::kEveryMs || t._type() == TaskType::kAtFramerate);
92 if (is_recurring) {
93 ++i; // Keep recurring tasks
94 } else {
95 // erase() returns bool in fl::vector, not iterator
96 mTasks.erase(mTasks.begin() + i);
97 // Don't increment i since we just removed an element
98 }
99 } else {
100 ++i;
101 }
102 }
103 }
105}
fl::vector< Handle > mTasks
Definition scheduler.h:46
void warn_no_then(int task_id, const fl::string &trace_label) FL_NO_EXCEPT
void update_frame_listener_registration() FL_NO_EXCEPT
@ kAtFramerate
Runs at a fixed number of times per second.
Definition task.h:119
@ kEveryMs
Runs after a fixed time interval.
Definition task.h:118
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.

References fl::FL_NO_EXCEPT, fl::task::kAtFramerate, fl::task::kEveryMs, fl::millis(), mTasks, fl::t, update_frame_listener_registration(), and warn_no_then().

Referenced by fl::FxEngine::draw(), and fl::task::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: