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

◆ update()

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

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

24 {
25 u32 current_time = fl::millis();
26
27 // Use index-based iteration to avoid iterator invalidation issues
28 for (fl::size i = 0; i < mTasks.size();) {
29 Handle& t = mTasks[i];
30
31 if (!t.is_valid() || t._is_canceled()) {
32 // erase() returns bool in fl::vector, not iterator
33 mTasks.erase(mTasks.begin() + i);
34 // Don't increment i since we just removed an element
35 } else {
36 // Check if task is ready to run (frame tasks will return false here)
37 bool should_run = t._ready_to_run(current_time);
38
39 if (should_run) {
40 // Update last run time for recurring tasks
41 t._set_last_run_time(current_time);
42
43 // Execute the task
44 if (t._has_then()) {
45 t._execute_then();
46 } else {
47 warn_no_then(t._id(), t._trace_label());
48 }
49
50 // Remove one-shot tasks, keep recurring ones
51 bool is_recurring = (t._type() == TaskType::kEveryMs || t._type() == TaskType::kAtFramerate);
52 if (is_recurring) {
53 ++i; // Keep recurring tasks
54 } else {
55 // erase() returns bool in fl::vector, not iterator
56 mTasks.erase(mTasks.begin() + i);
57 // Don't increment i since we just removed an element
58 }
59 } else {
60 ++i;
61 }
62 }
63 }
64}
void warn_no_then(int task_id, const fl::string &trace_label)
fl::vector< Handle > mTasks
Definition scheduler.h:39
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.

References fl::task::kAtFramerate, fl::task::kEveryMs, fl::millis(), mTasks, fl::t, 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: