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;
87 virtual
int id() const = 0;
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_NOEXCEPT
platforms::TaskCoroutinePtr mImpl
Coroutine(fl::string name, TaskFunction function, size_t stack_size=4096, u8 priority=5, int core_id=-1)
fl::function< void()> TaskFunction
~Coroutine() FL_NOEXCEPT=default
static void exitCurrent()
unique_ptr< string > mTraceLabel
void execute_catch(const Error &) override
bool ready_to_run_frame_task(fl::u32) const override
void auto_register_with_scheduler() override
bool ready_to_run(fl::u32) const override
CoroutineTask(const CoroutineConfig &config)
void set_id(int id) override
void execute_then() override
TaskType type() const override
string trace_label() const override
void set_last_run_time(fl::u32) override
bool is_canceled() const override
void set_then(function< void()>) override
bool is_auto_registered() const override
int interval_ms() const override
bool has_then() const override
bool isRunning() const override
bool has_catch() const override
unique_ptr< Coroutine > mCoroutine
void set_catch(function< void(const Error &)>) override
void set_interval_ms(int) override
void set_canceled() override
fl::u32 last_run_time() const override
Handle & then(function< void()> on_then) FL_NOEXCEPT
Handle() FL_NOEXCEPT=default
string trace_label() const FL_NOEXCEPT
bool _is_canceled() const FL_NOEXCEPT
int id() const FL_NOEXCEPT
bool isRunning() const FL_NOEXCEPT
bool _ready_to_run(u32 current_time) const FL_NOEXCEPT
bool ready_to_run(u32 current_time) const FL_NOEXCEPT
Handle & catch_(function< void(const Error &)> on_catch) FL_NOEXCEPT
void _set_last_run_time(u32 time) FL_NOEXCEPT
void _execute_then() FL_NOEXCEPT
bool is_valid() const FL_NOEXCEPT
u32 last_run_time() const FL_NOEXCEPT
bool _ready_to_run_frame_task(u32 current_time) const FL_NOEXCEPT
int _id() const FL_NOEXCEPT
TaskType type() const FL_NOEXCEPT
bool has_then() const FL_NOEXCEPT
bool has_catch() const FL_NOEXCEPT
bool isCoroutine() const FL_NOEXCEPT
void _execute_catch(const Error &error) FL_NOEXCEPT
bool _has_then() const FL_NOEXCEPT
int interval_ms() const FL_NOEXCEPT
string _trace_label() const FL_NOEXCEPT
Handle & cancel() FL_NOEXCEPT
void _set_id(int id) FL_NOEXCEPT
void set_interval_ms(int interval_ms) FL_NOEXCEPT
void set_last_run_time(u32 time) FL_NOEXCEPT
shared_ptr< ITaskImpl > mImpl
TaskType _type() const FL_NOEXCEPT
Task Handle with fluent API (was class fl::task, renamed to avoid namespace collision)
virtual bool is_auto_registered() const =0
virtual TaskType type() const =0
virtual void set_id(int id)=0
virtual bool has_catch() const =0
virtual void execute_then()=0
virtual void set_canceled()=0
virtual bool isRunning() const =0
virtual void set_interval_ms(int interval_ms)=0
virtual bool ready_to_run(u32 current_time) const =0
virtual string trace_label() const =0
virtual int interval_ms() const =0
virtual void set_last_run_time(u32 time)=0
virtual void set_catch(function< void(const Error &)> on_catch)=0
virtual bool ready_to_run_frame_task(u32 current_time) const =0
virtual void auto_register_with_scheduler()=0
virtual ~ITaskImpl() FL_NOEXCEPT=default
virtual bool is_canceled() const =0
virtual bool has_then() const =0
virtual void set_then(function< void()> on_then)=0
virtual void execute_catch(const Error &error)=0
virtual u32 last_run_time() const =0
static Scheduler & instance()
void execute_catch(const Error &error) override
void set_interval_ms(int interval_ms) override
string trace_label() const override
void execute_then() override
TimeTask(TaskType type, int interval_ms, optional< TracePoint > trace=nullopt)
bool is_canceled() const override
bool isRunning() const override
u32 last_run_time() const override
void set_id(int id) override
void set_canceled() override
bool is_auto_registered() const override
TaskType type() const override
bool ready_to_run(u32 current_time) const override
void set_catch(function< void(const Error &)> on_catch) override
void auto_register_with_scheduler() override
int interval_ms() const override
unique_ptr< string > mTraceLabel
void set_then(function< void()> on_then) override
bool has_then() const override
bool has_catch() const override
function< void()> mThenCallback
void set_last_run_time(u32 time) override
function< void(const Error &)> mCatchCallback
bool ready_to_run_frame_task(u32) const override
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
string make_trace_label(const TracePoint &trace)
Handle every_ms(int interval_ms)
Handle at_framerate(int fps)
Handle coroutine(const CoroutineConfig &config)
Configuration for OS-level coroutine tasks.
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
constexpr int type_rank< T >::value
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
fl::u64 time() FL_NOEXCEPT
Alias for millis64() - returns 64-bit millisecond time.
fl::enable_if<!fl::is_array< T >::value, unique_ptr< T > >::type make_unique(Args &&... args) FL_NOEXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
constexpr nullopt_t nullopt
pair_element< I, T1, T2 >::type & get(pair< T1, T2 > &p) FL_NOEXCEPT
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_NOEXCEPT