|
FastLED 3.10.8
|
Namespaces | |
| namespace | anonymous_namespace{task.cpp.hpp} |
| namespace | detail |
Classes | |
| class | Coroutine |
| struct | CoroutineConfig |
| Function and platform tuning for an OS-level coroutine task. More... | |
| class | CoroutineTask |
| struct | Error |
| Error type for promises. More... | |
| class | Executor |
| Task executor (singleton) — manages registered runners. More... | |
| class | Handle |
| Task Handle with fluent API (was class fl::task, renamed to avoid namespace collision) More... | |
| class | ITaskImpl |
| class | Promise |
| Promise class that provides fluent .then() and .catch_() semantics This is a lightweight wrapper around a shared PromiseImpl for easy copying/sharing. More... | |
| class | PromiseResult |
| Result type for promise operations. More... | |
| class | Runner |
| Generic task runner interface. More... | |
| class | Scheduler |
| class | TimeTask |
Enumerations | |
| enum class | ExecFlags : u8 { TASKS = 1 << 0 , COROUTINES = 1 << 1 , SYSTEM = 1 << 2 , ALL = (1 << 0) | (1 << 1) | (1 << 2) } |
| Flags controlling which subsystems run() pumps. More... | |
| enum class | TaskType { kEveryMs , kAtFramerate , kBeforeFrame , kAfterFrame , kCoroutine } |
| Identifies how a scheduled task is triggered. More... | |
Functions | |
| size_t | active_tasks () FL_NO_EXCEPT |
| Get the number of active tasks across all systems. | |
| Handle | after_frame () FL_NO_EXCEPT |
| Creates a task that runs after every FastLED frame until canceled. | |
| Handle | after_frame (const TracePoint &trace) FL_NO_EXCEPT |
| Creates a traced task that runs after every FastLED frame until canceled. | |
| Handle | after_frame (function< void()> on_then) FL_NO_EXCEPT |
| Creates an after-frame task, running until canceled, with its success callback already configured. | |
| Handle | after_frame (function< void()> on_then, const TracePoint &trace) FL_NO_EXCEPT |
| Creates a traced after-frame task, running until canceled, with its success callback already configured. | |
| Handle | at_framerate (int fps) FL_NO_EXCEPT |
| Creates a task that runs at a fixed frame rate. | |
| Handle | at_framerate (int fps, const TracePoint &trace) FL_NO_EXCEPT |
| Creates a traced task that runs at a fixed frame rate. | |
| template<typename T> | |
| PromiseResult< T > | await (Promise< T > p, fl::u32 timeout_ms=fl::platforms::kAwaitDefaultTimeoutMs) FL_NO_EXCEPT |
| Await promise completion in a coroutine (Trampoline to platform implementation) | |
| template<typename T> | |
| PromiseResult< T > | await_top_level (Promise< T > p) FL_NO_EXCEPT |
| Synchronously wait for a promise to complete (ONLY safe in top-level contexts) | |
| Handle | before_frame () FL_NO_EXCEPT |
| Frame tasks recur: every overload below schedules a task that runs once per FastLED frame and keeps doing so until Handle::cancel() is called on it, so keep the returned handle whenever the task will need to be canceled. | |
| Handle | before_frame (const TracePoint &trace) FL_NO_EXCEPT |
| Creates a traced task that runs before every FastLED frame until canceled. | |
| Handle | coroutine (const CoroutineConfig &config) FL_NO_EXCEPT |
| Creates and starts an OS-level coroutine task. | |
| Handle | every_ms (int interval_ms) FL_NO_EXCEPT |
| Creates a task that runs at a fixed millisecond interval. | |
| Handle | every_ms (int interval_ms, const TracePoint &trace) FL_NO_EXCEPT |
| Creates a traced task that runs at a fixed millisecond interval. | |
| void | exit_current () FL_NO_EXCEPT |
| Terminates the currently executing coroutine. | |
| bool | has_tasks () FL_NO_EXCEPT |
| Check if any systems have active tasks. | |
| template<typename T> | |
| PromiseResult< T > | make_error (const char *message) FL_NO_EXCEPT |
| Helper function to create an error result from C-string. | |
| template<typename T> | |
| PromiseResult< T > | make_error (const Error &error) FL_NO_EXCEPT |
| Helper function to create an error result. | |
| template<typename T> | |
| PromiseResult< T > | make_error (const fl::string &message) FL_NO_EXCEPT |
| Helper function to create an error result from string. | |
| template<typename T> | |
| PromiseResult< T > | make_error (Error &&error) FL_NO_EXCEPT |
| Helper function to create an error result (move) | |
| template<typename T> | |
| Promise< T > | make_rejected_promise (const char *error_message) FL_NO_EXCEPT |
| Convenience function to create a rejected Promise (const char* overload) | |
| template<typename T> | |
| Promise< T > | make_rejected_promise (const fl::string &error_message) FL_NO_EXCEPT |
| Convenience function to create a rejected Promise. | |
| template<typename T> | |
| Promise< T > | make_resolved_promise (T value) FL_NO_EXCEPT |
| Convenience function to create a resolved Promise. | |
| template<typename T> | |
| PromiseResult< T > | make_success (const T &value) FL_NO_EXCEPT |
| Helper function to create a successful result. | |
| template<typename T> | |
| PromiseResult< T > | make_success (T &&value) FL_NO_EXCEPT |
| Helper function to create a successful result (move) | |
| bool | operator& (ExecFlags a, ExecFlags b) FL_NO_EXCEPT |
| ExecFlags | operator| (ExecFlags a, ExecFlags b) FL_NO_EXCEPT |
| void | run (fl::u32 microseconds=1000, ExecFlags flags=ExecFlags::ALL) FL_NO_EXCEPT |
| Run selected task subsystems. | |
| void | yield_system (fl::u32 microseconds) FL_NO_EXCEPT |
OS-level yield only: same behavior as run(us, ExecFlags::SYSTEM). | |
Only ESP32 honors it; a value outside [0, FL_CPU_CORES) is silently downgraded to no affinity, and single-core or non-RTOS platforms ignore the field.
An empty function is legal: the coroutine starts, does nothing, and exits.
On ESP32 the FreeRTOS priority becomes tskIDLE_PRIORITY + priority. FastLED does not clamp this against the platform maximum.
A platform may raise a smaller request to its own floor (ESP32 clamps up to 2048) and platforms that emulate coroutines may ignore the field entirely.
Unset by default, in which case the label is empty.
|
strong |
Flags controlling which subsystems run() pumps.
| Enumerator | |
|---|---|
| TASKS | |
| COROUTINES | |
| SYSTEM | |
| ALL | |
Definition at line 64 of file executor.h.
|
strong |
Identifies how a scheduled task is triggered.
Definition at line 117 of file task.h.
| size_t fl::task::active_tasks | ( | ) |
Get the number of active tasks across all systems.
Definition at line 188 of file executor.cpp.hpp.
References fl::FL_NO_EXCEPT, fl::task::Executor::instance(), and fl::task::Executor::total_active_tasks().
Here is the call graph for this function:| Handle fl::task::after_frame | ( | ) |
Creates a task that runs after every FastLED frame until canceled.
Definition at line 344 of file task.cpp.hpp.
References fl::FL_NO_EXCEPT, kAfterFrame, and fl::adl_barrier::make_shared().
Referenced by after_frame(), and after_frame().
Here is the call graph for this function:
Here is the caller graph for this function:| Handle fl::task::after_frame | ( | const TracePoint & | trace | ) |
Creates a traced task that runs after every FastLED frame until canceled.
| trace | Location where the task was created. |
Definition at line 348 of file task.cpp.hpp.
References fl::FL_NO_EXCEPT, kAfterFrame, and fl::adl_barrier::make_shared().
Here is the call graph for this function:Creates an after-frame task, running until canceled, with its success callback already configured.
| on_then | Callback invoked after each FastLED frame. |
Definition at line 352 of file task.cpp.hpp.
References after_frame(), fl::FL_NO_EXCEPT, fl::adl_barrier::move(), and fl::t.
Here is the call graph for this function:| Handle fl::task::after_frame | ( | function< void()> | on_then, |
| const TracePoint & | trace ) |
Creates a traced after-frame task, running until canceled, with its success callback already configured.
| on_then | Callback invoked after each FastLED frame. |
| trace | Location where the task was created. |
Definition at line 358 of file task.cpp.hpp.
References after_frame(), fl::FL_NO_EXCEPT, fl::adl_barrier::move(), and fl::t.
Here is the call graph for this function:| Handle fl::task::at_framerate | ( | int | fps | ) |
Creates a task that runs at a fixed frame rate.
| fps | Number of executions per second. |
Definition at line 328 of file task.cpp.hpp.
References fl::FL_NO_EXCEPT, kAtFramerate, and fl::adl_barrier::make_shared().
Referenced by setup().
Here is the call graph for this function:
Here is the caller graph for this function:| Handle fl::task::at_framerate | ( | int | fps, |
| const TracePoint & | trace ) |
Creates a traced task that runs at a fixed frame rate.
| fps | Number of executions per second. |
| trace | Location where the task was created. |
Definition at line 332 of file task.cpp.hpp.
References fl::FL_NO_EXCEPT, kAtFramerate, and fl::adl_barrier::make_shared().
Here is the call graph for this function:
|
inline |
Await promise completion in a coroutine (Trampoline to platform implementation)
| T | The type of value the promise resolves to |
| p | The promise to await |
This is the public API for awaiting promises in coroutines. It delegates to the platform-specific implementation in fl::platforms::await().
REQUIREMENTS:
SAFETY: Unlike await_top_level(), this does NOT busy-wait. The coroutine is suspended by the OS scheduler and wakes when the promise completes, with zero CPU overhead.
| timeout_ms | Wall-clock budget before the wait returns an error rather than continuing to poll. Defaults to fl::platforms::kAwaitDefaultTimeoutMs; see FastLED#4369 for why the wait is bounded at all. |
Definition at line 316 of file executor.h.
References fl::FL_NO_EXCEPT.
| PromiseResult< T > fl::task::await_top_level | ( | Promise< T > | p | ) |
Synchronously wait for a promise to complete (ONLY safe in top-level contexts)
| T | The type of value the promise resolves to (automatically deduced) |
| p | The promise to wait for |
This function blocks until the promise is either resolved or rejected, then returns a promise_result that can be checked with ok() for success/failure. While waiting, it continuously calls run(1000) to pump async tasks and yield appropriately.
PERFORMANCE NOTE: This function busy-waits (high CPU usage) while the promise is pending. For coroutines on ESP32 or Host/Stub platforms, prefer fl::task::await() which truly blocks the coroutine with zero CPU overhead.
SAFETY WARNING: This function should ONLY be called from top-level contexts like Arduino loop() function. Never call this from:
The "_top_level" suffix emphasizes this safety requirement.
Definition at line 193 of file executor.h.
References await_top_level(), and fl::FL_NO_EXCEPT.
Referenced by await_top_level(), test_await_approach(), test_get_endpoint(), test_json_await(), test_json_endpoint(), and test_ping_endpoint().
Here is the call graph for this function:
Here is the caller graph for this function:| Handle fl::task::before_frame | ( | ) |
Frame tasks recur: every overload below schedules a task that runs once per FastLED frame and keeps doing so until Handle::cancel() is called on it, so keep the returned handle whenever the task will need to be canceled.
Creates a task that runs before every FastLED frame until canceled.
Definition at line 336 of file task.cpp.hpp.
References fl::FL_NO_EXCEPT, kBeforeFrame, and fl::adl_barrier::make_shared().
Here is the call graph for this function:| Handle fl::task::before_frame | ( | const TracePoint & | trace | ) |
Creates a traced task that runs before every FastLED frame until canceled.
| trace | Location where the task was created. |
Definition at line 340 of file task.cpp.hpp.
References fl::FL_NO_EXCEPT, kBeforeFrame, and fl::adl_barrier::make_shared().
Here is the call graph for this function:| Handle fl::task::coroutine | ( | const CoroutineConfig & | config | ) |
Creates and starts an OS-level coroutine task.
| config | Function and platform-specific task configuration. |
Definition at line 364 of file task.cpp.hpp.
References fl::FL_NO_EXCEPT, and fl::adl_barrier::make_shared().
Here is the call graph for this function:| Handle fl::task::every_ms | ( | int | interval_ms | ) |
Creates a task that runs at a fixed millisecond interval.
| interval_ms | Interval between runs. |
Definition at line 320 of file task.cpp.hpp.
References fl::FL_NO_EXCEPT, fl::task::ITaskImpl::interval_ms(), kEveryMs, and fl::adl_barrier::make_shared().
Referenced by fl::detail::AsyncLoggerServiceTask::AsyncLoggerServiceTask(), fl::audio::Processor::createWithAutoInput(), autoresearch::maybeRegisterStubAutorun(), setup(), and autoresearch::setupRpcAsyncTask().
Here is the call graph for this function:
Here is the caller graph for this function:| Handle fl::task::every_ms | ( | int | interval_ms, |
| const TracePoint & | trace ) |
Creates a traced task that runs at a fixed millisecond interval.
| interval_ms | Interval between runs. |
| trace | Location where the task was created. |
Definition at line 324 of file task.cpp.hpp.
References fl::FL_NO_EXCEPT, fl::task::ITaskImpl::interval_ms(), kEveryMs, and fl::adl_barrier::make_shared().
Here is the call graph for this function:| void fl::task::exit_current | ( | ) |
Terminates the currently executing coroutine.
Definition at line 369 of file task.cpp.hpp.
References fl::task::Coroutine::exitCurrent(), and fl::FL_NO_EXCEPT.
Here is the call graph for this function:| bool fl::task::has_tasks | ( | ) |
Check if any systems have active tasks.
Definition at line 192 of file executor.cpp.hpp.
References fl::FL_NO_EXCEPT, fl::task::Executor::has_active_tasks(), and fl::task::Executor::instance().
Here is the call graph for this function:| PromiseResult< T > fl::task::make_error | ( | const char * | message | ) |
Helper function to create an error result from C-string.
| T | The value type |
| message | The error message |
Definition at line 179 of file promise_result.h.
References fl::Error, and fl::FL_NO_EXCEPT.
| PromiseResult< T > fl::task::make_error | ( | const Error & | error | ) |
Helper function to create an error result.
| T | The value type |
| error | The error |
Definition at line 152 of file promise_result.h.
References fl::FL_NO_EXCEPT.
| PromiseResult< T > fl::task::make_error | ( | const fl::string & | message | ) |
Helper function to create an error result from string.
| T | The value type |
| message | The error message |
Definition at line 170 of file promise_result.h.
References fl::Error, and fl::FL_NO_EXCEPT.
| PromiseResult< T > fl::task::make_error | ( | Error && | error | ) |
Helper function to create an error result (move)
| T | The value type |
| error | The error (moved) |
Definition at line 161 of file promise_result.h.
References fl::FL_NO_EXCEPT, and fl::adl_barrier::move().
Here is the call graph for this function:| Promise< T > fl::task::make_rejected_promise | ( | const char * | error_message | ) |
Convenience function to create a rejected Promise (const char* overload)
Definition at line 226 of file promise.h.
References fl::Error, fl::FL_NO_EXCEPT, and fl::task::Promise< T >::reject().
Here is the call graph for this function:| Promise< T > fl::task::make_rejected_promise | ( | const fl::string & | error_message | ) |
Convenience function to create a rejected Promise.
Definition at line 220 of file promise.h.
References fl::Error, fl::FL_NO_EXCEPT, and fl::task::Promise< T >::reject().
Here is the call graph for this function:| Promise< T > fl::task::make_resolved_promise | ( | T | value | ) |
Convenience function to create a resolved Promise.
Definition at line 214 of file promise.h.
References fl::FL_NO_EXCEPT, fl::adl_barrier::move(), fl::task::Promise< T >::resolve(), and fl::type_rank< T >::value.
Here is the call graph for this function:| PromiseResult< T > fl::task::make_success | ( | const T & | value | ) |
Helper function to create a successful result.
| T | The value type |
| value | The success value |
Definition at line 134 of file promise_result.h.
References fl::FL_NO_EXCEPT, and fl::type_rank< T >::value.
| PromiseResult< T > fl::task::make_success | ( | T && | value | ) |
Helper function to create a successful result (move)
| T | The value type |
| value | The success value (moved) |
Definition at line 143 of file promise_result.h.
References fl::FL_NO_EXCEPT, fl::adl_barrier::move(), and fl::type_rank< T >::value.
Here is the call graph for this function:| void fl::task::run | ( | fl::u32 | microseconds = 1000, |
| ExecFlags | flags = ExecFlags::ALL ) |
Run selected task subsystems.
Pumps the requested subsystems and yields for up to microseconds.
Usage:
run() — pump ALL + yield for 1ms (default)run(0) — pump ALL, no yieldrun(250, ExecFlags::SYSTEM) — OS yield only; prefer yield_system(250)run(1000, ExecFlags::TASKS | ExecFlags::COROUTINES) — skip OS yield| microseconds | Budget in microseconds (default 1000 = 1ms) |
| flags | Which subsystems to pump (default ALL) |
Definition at line 76 of file executor.cpp.hpp.
References COROUTINES, fl::FL_NO_EXCEPT, FL_WARN_ONCE, fl::SingletonThreadLocal< T, N >::instance(), fl::task::Executor::instance(), fl::task::Scheduler::instance(), fl::make_scope_exit(), fl::micros(), fl::min(), SYSTEM, TASKS, fl::task::Scheduler::update(), fl::task::Executor::update_all(), and fl::yield().
Referenced by fl::detail::delay_impl(), fl::net::http::fetch_update(), loop(), and fl::net::http::FetchEngineListener::onEndFrame().
Here is the call graph for this function:
Here is the caller graph for this function:| void fl::task::yield_system | ( | fl::u32 | microseconds | ) |
OS-level yield only: same behavior as run(us, ExecFlags::SYSTEM).
Prefer this in driver/DMA wait loops. run() dispatches on its flags at runtime, so even a SYSTEM-only call links the task Scheduler and Executor into every sketch; this entry point references neither (#4797). microseconds > 0 deep-yields (>= 1 FreeRTOS tick on ESP32) until the budget is spent; 0 is a single lightweight fl::yield().
Definition at line 172 of file executor.cpp.hpp.
References fl::FL_NO_EXCEPT, fl::micros(), fl::min(), and fl::yield().
Referenced by throttleToMaxRefreshRate(), fl::ChannelManager::waitForCondition(), and fl::IChannelDriver::waitForCondition().
Here is the call graph for this function:
Here is the caller graph for this function: