7#include "platforms/coroutine.h"
17 ss << fl::get<0>(trace) <<
":" <<
fl::get<1>(trace);
24 return id.fetch_add(1) + 1;
64 platforms::ICoroutineTask::exitCurrent();
68 platforms::TaskCoroutinePtr
mImpl;
222 config.core_id.has_value() ? config.core_id.value() : -1)) {}
279 if (!
mImpl->is_auto_registered()) {
280 mImpl->auto_register_with_scheduler();
296 mImpl->set_canceled();
string str() const FL_NO_EXCEPT
bool isRunning() const FL_NO_EXCEPT
platforms::TaskCoroutinePtr mImpl
static void exitCurrent() FL_NO_EXCEPT
fl::function< void()> TaskFunction
Coroutine(fl::string name, TaskFunction function, size_t stack_size=4096, u8 priority=5, int core_id=-1) FL_NO_EXCEPT
~Coroutine() FL_NO_EXCEPT=default
string trace_label() const FL_NO_EXCEPT override
bool has_catch() const FL_NO_EXCEPT override
void execute_catch(const Error &) FL_NO_EXCEPT override
void set_canceled() FL_NO_EXCEPT override
void set_catch(function< void(const Error &)>) FL_NO_EXCEPT override
unique_ptr< string > mTraceLabel
CoroutineTask(const CoroutineConfig &config) FL_NO_EXCEPT
fl::u32 last_run_time() const FL_NO_EXCEPT override
bool is_canceled() const FL_NO_EXCEPT override
int interval_ms() const FL_NO_EXCEPT override
void execute_then() FL_NO_EXCEPT override
void set_interval_ms(int) FL_NO_EXCEPT override
TaskType type() const FL_NO_EXCEPT override
bool has_then() const FL_NO_EXCEPT override
void set_then(function< void()>) FL_NO_EXCEPT override
bool ready_to_run(fl::u32) const FL_NO_EXCEPT override
bool is_auto_registered() const FL_NO_EXCEPT override
void set_last_run_time(fl::u32) FL_NO_EXCEPT override
bool ready_to_run_frame_task(fl::u32) const FL_NO_EXCEPT override
void auto_register_with_scheduler() FL_NO_EXCEPT override
unique_ptr< Coroutine > mCoroutine
bool isRunning() const FL_NO_EXCEPT override
void set_id(int id) FL_NO_EXCEPT override
int id() const FL_NO_EXCEPT override
void stop() FL_NO_EXCEPT override
int interval_ms() const FL_NO_EXCEPT
Returns the interval between runs, in milliseconds.
void set_last_run_time(u32 time) FL_NO_EXCEPT
Records the timestamp of the most recent run.
u32 last_run_time() const FL_NO_EXCEPT
Returns the timestamp of the most recent run, in milliseconds.
Handle & then(function< void()> on_then) FL_NO_EXCEPT
Sets the callback invoked when the task runs successfully.
bool has_then() const FL_NO_EXCEPT
Returns whether a success callback is configured.
bool _has_then() const FL_NO_EXCEPT
int _id() const FL_NO_EXCEPT
void _execute_catch(const Error &error) FL_NO_EXCEPT
void _execute_then() FL_NO_EXCEPT
Handle & catch_(function< void(const Error &)> on_catch) FL_NO_EXCEPT
Sets the callback invoked when task execution reports an error.
bool _is_canceled() const FL_NO_EXCEPT
void stop() FL_NO_EXCEPT
Stops the coroutine represented by this handle.
bool _ready_to_run(u32 current_time) const FL_NO_EXCEPT
Handle & cancel() FL_NO_EXCEPT
Prevents future scheduled executions of the task.
void set_interval_ms(int interval_ms) FL_NO_EXCEPT
Changes the interval between runs.
bool is_valid() const FL_NO_EXCEPT
Returns whether this handle refers to a task.
bool isRunning() const FL_NO_EXCEPT
Returns whether the represented coroutine is currently running.
int id() const FL_NO_EXCEPT
Returns the task's unique identifier.
bool has_catch() const FL_NO_EXCEPT
Returns whether an error callback is configured.
bool isCoroutine() const FL_NO_EXCEPT
Returns whether this handle refers to an OS-level coroutine.
TaskType _type() const FL_NO_EXCEPT
Handle() FL_NO_EXCEPT=default
Constructs an empty, invalid handle.
string _trace_label() const FL_NO_EXCEPT
bool ready_to_run(u32 current_time) const FL_NO_EXCEPT
Tests whether the task is ready at a given timestamp.
bool _ready_to_run_frame_task(u32 current_time) const FL_NO_EXCEPT
void _set_last_run_time(u32 time) FL_NO_EXCEPT
string trace_label() const FL_NO_EXCEPT
Returns the label of the task's creation trace, if available.
void _set_id(int id) FL_NO_EXCEPT
shared_ptr< ITaskImpl > mImpl
TaskType type() const FL_NO_EXCEPT
Returns the task's scheduling mode.
Task Handle with fluent API (was class fl::task, renamed to avoid namespace collision)
virtual int interval_ms() const FL_NO_EXCEPT=0
virtual void set_canceled() FL_NO_EXCEPT=0
virtual void execute_then() FL_NO_EXCEPT=0
virtual bool is_auto_registered() const FL_NO_EXCEPT=0
virtual bool ready_to_run_frame_task(u32 current_time) const FL_NO_EXCEPT=0
virtual void set_last_run_time(u32 time) FL_NO_EXCEPT=0
virtual bool ready_to_run(u32 current_time) const FL_NO_EXCEPT=0
virtual void set_interval_ms(int interval_ms) FL_NO_EXCEPT=0
virtual void execute_catch(const Error &error) FL_NO_EXCEPT=0
virtual bool isRunning() const FL_NO_EXCEPT=0
virtual void auto_register_with_scheduler() FL_NO_EXCEPT=0
virtual void stop() FL_NO_EXCEPT=0
virtual void set_catch(function< void(const Error &)> on_catch) FL_NO_EXCEPT=0
virtual TaskType type() const FL_NO_EXCEPT=0
virtual ~ITaskImpl() FL_NO_EXCEPT=default
virtual bool is_canceled() const FL_NO_EXCEPT=0
virtual u32 last_run_time() const FL_NO_EXCEPT=0
virtual void set_id(int id) FL_NO_EXCEPT=0
virtual bool has_catch() const FL_NO_EXCEPT=0
virtual void set_then(function< void()> on_then) FL_NO_EXCEPT=0
virtual string trace_label() const FL_NO_EXCEPT=0
virtual bool has_then() const FL_NO_EXCEPT=0
static Scheduler & instance() FL_NO_EXCEPT
int add_task(Handle t) FL_NO_EXCEPT
void set_interval_ms(int interval_ms) FL_NO_EXCEPT override
u32 last_run_time() const FL_NO_EXCEPT override
bool has_catch() const FL_NO_EXCEPT override
void set_last_run_time(u32 time) FL_NO_EXCEPT override
bool is_canceled() const FL_NO_EXCEPT override
void stop() FL_NO_EXCEPT override
int id() const FL_NO_EXCEPT override
void set_canceled() FL_NO_EXCEPT override
bool is_auto_registered() const FL_NO_EXCEPT override
bool has_then() const FL_NO_EXCEPT override
string trace_label() const FL_NO_EXCEPT override
void set_then(function< void()> on_then) FL_NO_EXCEPT override
TaskType type() const FL_NO_EXCEPT override
void set_catch(function< void(const Error &)> on_catch) FL_NO_EXCEPT override
TimeTask(TaskType type, int interval_ms, optional< TracePoint > trace=nullopt) FL_NO_EXCEPT
void auto_register_with_scheduler() FL_NO_EXCEPT override
bool ready_to_run(u32 current_time) const FL_NO_EXCEPT override
void execute_catch(const Error &error) FL_NO_EXCEPT override
bool ready_to_run_frame_task(u32) const FL_NO_EXCEPT override
unique_ptr< string > mTraceLabel
int interval_ms() const FL_NO_EXCEPT override
void set_id(int id) FL_NO_EXCEPT override
bool isRunning() const FL_NO_EXCEPT override
function< void()> mThenCallback
void execute_then() FL_NO_EXCEPT override
function< void(const Error &)> mCatchCallback
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
fl::enable_if<!fl::is_array< T >::value, unique_ptr< T > >::type make_unique(Args &&... args) FL_NO_EXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
string make_trace_label(const TracePoint &trace) FL_NO_EXCEPT
int next_task_id() FL_NO_EXCEPT
Handle before_frame() FL_NO_EXCEPT
Frame tasks recur: every overload below schedules a task that runs once per FastLED frame and keeps d...
Handle after_frame() FL_NO_EXCEPT
Creates a task that runs after every FastLED frame until canceled.
Handle coroutine(const CoroutineConfig &config) FL_NO_EXCEPT
Creates and starts an OS-level coroutine task.
Handle at_framerate(int fps) FL_NO_EXCEPT
Creates a task that runs at a fixed frame rate.
Handle every_ms(int interval_ms) FL_NO_EXCEPT
Creates a task that runs at a fixed millisecond interval.
TaskType
Identifies how a scheduled task is triggered.
@ kBeforeFrame
Runs immediately before each FastLED frame is rendered.
@ kAfterFrame
Runs immediately after each FastLED frame is rendered.
@ kAtFramerate
Runs at a fixed number of times per second.
@ kEveryMs
Runs after a fixed time interval.
@ kCoroutine
Runs as an operating-system or RTOS task.
void exit_current() FL_NO_EXCEPT
Terminates the currently executing coroutine.
Function and platform tuning for an OS-level coroutine task.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
fl::u64 time() FL_NO_EXCEPT
Alias for millis64() - returns 64-bit millisecond time.
constexpr nullopt_t nullopt
pair_element< I, T1, T2 >::type & get(pair< T1, T2 > &p) FL_NO_EXCEPT
fl::tuple< const char *, int, fl::u32 > TracePoint
A structure to hold source trace information.
Base definition for an LED controller.
Task scheduler — manages timer and frame-based tasks.
static constexpr T max() FL_NO_EXCEPT