MCPcopy Create free account
hub / github.com/FastLED/FastLED / update

Method update

src/fl/task/scheduler.cpp.hpp:24–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24void Scheduler::update() {
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}
65
66void Scheduler::update_before_frame_tasks() {
67 update_tasks_of_type(TaskType::kBeforeFrame);

Callers 4

update_allMethod · 0.45
runFunction · 0.45
await_top_levelFunction · 0.45
PromiseClass · 0.45

Calls 13

_is_canceledMethod · 0.80
_ready_to_runMethod · 0.80
_set_last_run_timeMethod · 0.80
_has_thenMethod · 0.80
_execute_thenMethod · 0.80
_idMethod · 0.80
_trace_labelMethod · 0.80
_typeMethod · 0.80
millisFunction · 0.50
sizeMethod · 0.45
is_validMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected