11extern "C" void emscripten_sleep(
unsigned int ms);
43 for (
const auto* runner :
mRunners) {
44 if (runner && runner->has_active_tasks()) {
53 for (
const auto* runner :
mRunners) {
55 total += runner->active_task_count();
77 for (
int i = 0; i < 5; ++i) {
98 int task_id =
t.get_impl()->mTaskId;
109 for (fl::size i = 0; i <
mTasks.size();) {
111 auto impl =
t.get_impl();
113 if (!impl || impl->is_canceled()) {
119 bool should_run = impl->ready_to_run(current_time);
123 impl->set_last_run_time(current_time);
126 if (impl->has_then()) {
127 impl->execute_then();
160 for (fl::size i = 0; i <
mTasks.size();) {
162 auto impl =
t.get_impl();
164 if (!impl || impl->is_canceled()) {
168 }
else if (impl->type() == task_type) {
170 bool should_run = impl->ready_to_run_frame_task(current_time);
174 impl->set_last_run_time(current_time);
177 if (impl->has_then()) {
178 impl->execute_then();
196 if (!trace_label.
empty()) {
197 FL_WARN(
fl::string(
"[fl::task] Warning: no then() callback set for Task#") << task_id <<
" launched at " << trace_label);
199 FL_WARN(
fl::string(
"[fl::task] Warning: no then() callback set for Task#") << task_id);
204 if (!trace_label.
empty()) {
205 FL_WARN(
fl::string(
"[fl::task] Warning: no catch_() callback set for Task#") << task_id <<
" launched at " << trace_label <<
". Error: " << error.
message);
207 FL_WARN(
fl::string(
"[fl/task] Warning: no catch_() callback set for Task#") << task_id <<
". Error: " << error.
message);
size_t total_active_tasks() const
Get total number of active tasks across all runners.
bool has_active_tasks() const
Check if there are any active async tasks.
static AsyncManager & instance()
void update_all()
Update all registered async runners.
void register_runner(async_runner *runner)
Register an async runner.
fl::vector< async_runner * > mRunners
void unregister_runner(async_runner *runner)
Unregister an async runner.
Async task manager (singleton)
static Scheduler & instance()
void update_before_frame_tasks()
void warn_no_catch(int task_id, const fl::string &trace_label, const Error &error)
void update_after_frame_tasks()
fl::vector< task > mTasks
void warn_no_then(int task_id, const fl::string &trace_label)
void update_tasks_of_type(TaskType task_type)
Generic asynchronous task runner interface.
Universal timing functions for FastLED.
constexpr remove_reference< T >::type && move(T &&t) noexcept
Iterator find(Iterator first, Iterator last, const T &value)
void async_yield()
Platform-specific async yield function.
size_t async_active_tasks()
Get the number of active async tasks across all systems.
fl::u32 time()
Universal millisecond timer - returns milliseconds since system startup.
void async_run()
Run all registered async tasks once.
bool async_has_tasks()
Check if any async systems have active tasks.
Generic asynchronous task management for FastLED.