@brief Task Handle with fluent API (was class fl::task, renamed to avoid namespace collision)
| 137 | |
| 138 | /// @brief Task Handle with fluent API (was class fl::task, renamed to avoid namespace collision) |
| 139 | class Handle { |
| 140 | public: |
| 141 | |
| 142 | // Default constructor |
| 143 | Handle() FL_NOEXCEPT = default; |
| 144 | |
| 145 | // Copy and Move semantics (now possible with shared_ptr) |
| 146 | Handle(const Handle&) FL_NOEXCEPT = default; |
| 147 | Handle& operator=(const Handle&) FL_NOEXCEPT = default; |
| 148 | Handle(Handle&&) FL_NOEXCEPT = default; |
| 149 | Handle& operator=(Handle&&) FL_NOEXCEPT = default; |
| 150 | |
| 151 | // Constructor from impl - public because ITaskImpl is only forward-declared |
| 152 | // in the header, making this effectively private to external consumers |
| 153 | explicit Handle(shared_ptr<ITaskImpl> impl) FL_NOEXCEPT; |
| 154 | |
| 155 | // Fluent API |
| 156 | Handle& then(function<void()> on_then) FL_NOEXCEPT; |
| 157 | Handle& catch_(function<void(const Error&)> on_catch) FL_NOEXCEPT; |
| 158 | Handle& cancel() FL_NOEXCEPT; |
| 159 | |
| 160 | // Getters |
| 161 | int id() const FL_NOEXCEPT; |
| 162 | bool has_then() const FL_NOEXCEPT; |
| 163 | bool has_catch() const FL_NOEXCEPT; |
| 164 | string trace_label() const FL_NOEXCEPT; |
| 165 | TaskType type() const FL_NOEXCEPT; |
| 166 | int interval_ms() const FL_NOEXCEPT; |
| 167 | void set_interval_ms(int interval_ms) FL_NOEXCEPT; |
| 168 | u32 last_run_time() const FL_NOEXCEPT; |
| 169 | void set_last_run_time(u32 time) FL_NOEXCEPT; |
| 170 | bool ready_to_run(u32 current_time) const FL_NOEXCEPT; |
| 171 | bool is_valid() const FL_NOEXCEPT; |
| 172 | bool isCoroutine() const FL_NOEXCEPT; |
| 173 | |
| 174 | // Coroutine control (only valid if isCoroutine() == true) |
| 175 | void stop() FL_NOEXCEPT; |
| 176 | bool isRunning() const FL_NOEXCEPT; |
| 177 | |
| 178 | private: |
| 179 | friend class Scheduler; |
| 180 | |
| 181 | // Internal methods for Scheduler (friend access only) |
| 182 | void _set_id(int id) FL_NOEXCEPT; |
| 183 | int _id() const FL_NOEXCEPT; |
| 184 | bool _is_canceled() const FL_NOEXCEPT; |
| 185 | bool _ready_to_run(u32 current_time) const FL_NOEXCEPT; |
| 186 | bool _ready_to_run_frame_task(u32 current_time) const FL_NOEXCEPT; |
| 187 | void _set_last_run_time(u32 time) FL_NOEXCEPT; |
| 188 | bool _has_then() const FL_NOEXCEPT; |
| 189 | void _execute_then() FL_NOEXCEPT; |
| 190 | void _execute_catch(const Error& error) FL_NOEXCEPT; |
| 191 | TaskType _type() const FL_NOEXCEPT; |
| 192 | string _trace_label() const FL_NOEXCEPT; |
| 193 | |
| 194 | shared_ptr<ITaskImpl> mImpl; |
| 195 | }; |
| 196 |
no outgoing calls
no test coverage detected