FastLED 3.9.15
Loading...
Searching...
No Matches

◆ update()

void fl::Scheduler::update ( )

Definition at line 105 of file async.cpp.

105 {
106 uint32_t current_time = fl::time();
107
108 // Use index-based iteration to avoid iterator invalidation issues
109 for (fl::size i = 0; i < mTasks.size();) {
110 task& t = mTasks[i];
111 auto impl = t.get_impl();
112
113 if (!impl || impl->is_canceled()) {
114 // erase() returns bool in HeapVector, not iterator
115 mTasks.erase(mTasks.begin() + i);
116 // Don't increment i since we just removed an element
117 } else {
118 // Check if task is ready to run (frame tasks will return false here)
119 bool should_run = impl->ready_to_run(current_time);
120
121 if (should_run) {
122 // Update last run time for recurring tasks
123 impl->set_last_run_time(current_time);
124
125 // Execute the task
126 if (impl->has_then()) {
127 impl->execute_then();
128 } else {
129 warn_no_then(impl->id(), impl->trace_label());
130 }
131
132 // Remove one-shot tasks, keep recurring ones
133 bool is_recurring = (impl->type() == TaskType::kEveryMs || impl->type() == TaskType::kAtFramerate);
134 if (is_recurring) {
135 ++i; // Keep recurring tasks
136 } else {
137 // erase() returns bool in HeapVector, not iterator
138 mTasks.erase(mTasks.begin() + i);
139 // Don't increment i since we just removed an element
140 }
141 } else {
142 ++i;
143 }
144 }
145 }
146}
fl::vector< task > mTasks
Definition async.h:256
void warn_no_then(int task_id, const fl::string &trace_label)
Definition async.cpp:195
static uint32_t t
Definition Luminova.h:54
fl::u32 time()
Universal millisecond timer - returns milliseconds since system startup.
Definition time.cpp:136
@ kAtFramerate
Definition task.h:45
@ kEveryMs
Definition task.h:44

References fl::kAtFramerate, fl::kEveryMs, mTasks, t, fl::time(), and warn_no_then().

Referenced by fl::async_run().

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