FastLED 3.10.8
Loading...
Searching...
No Matches
executor.h File Reference

Detailed Description

Task executor — runs registered task runners and manages the run loop.

This module provides a unified system for managing background operations across FastLED, including HTTP requests, timers, and other background tasks.

The executor is pumped by fl::task::run(). Platform code may also call run() while yielding, but FastLED.show() does not update registered runners.

Examples

// Create a custom runner
class MyRunner : public fl::task::Runner {
public:
void update() override {
// Process your tasks here
process_timers();
handle_network_events();
}
bool has_active_tasks() const override {
return !mTimers.empty() || mNetworkActive;
}
size_t active_task_count() const override {
return mTimers.size() + (mNetworkActive ? 1 : 0);
}
};
void setup() {
MyRunner* runner = new MyRunner();
// Pump registered runners from loop().
}
void setup()
void register_runner(Runner *r) FL_NO_EXCEPT
Register a runner.
static Executor & instance() FL_NO_EXCEPT
virtual size_t active_task_count() const FL_NO_EXCEPT=0
Get number of active tasks (for debugging/monitoring)
virtual bool has_active_tasks() const FL_NO_EXCEPT=0
Check if this runner has active tasks.
virtual void update() FL_NO_EXCEPT=0
Update this runner (called during task pumping)
Generic task runner interface.
Definition executor.h:86
Task executor — runs registered task runners and manages the run loop.
void run(fl::u32 microseconds, ExecFlags flags) FL_NO_EXCEPT
Run selected task subsystems.

Definition in file executor.h.

#include "fl/task/promise.h"
#include "fl/task/promise_result.h"
#include "fl/task/scheduler.h"
#include "fl/stl/singleton.h"
#include "fl/task/task.h"
#include "platforms/await.h"
#include "fl/stl/cstddef.h"
#include "fl/stl/stdint.h"
#include "fl/stl/vector.h"
#include "fl/stl/noexcept.h"
+ Include dependency graph for executor.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  fl::task::Executor
 Task executor (singleton) — manages registered runners. More...
 
class  fl::task::Runner
 Generic task runner interface. More...
 

Namespaces

namespace  fl
 Base definition for an LED controller.
 
namespace  fl::task
 
namespace  fl::task::detail
 

Enumerations

enum class  fl::task::ExecFlags : u8 { fl::task::TASKS = 1 << 0 , fl::task::COROUTINES = 1 << 1 , fl::task::SYSTEM = 1 << 2 , fl::task::ALL = (1 << 0) | (1 << 1) | (1 << 2) }
 Flags controlling which subsystems run() pumps. More...
 

Functions

size_t fl::task::active_tasks () FL_NO_EXCEPT
 Get the number of active tasks across all systems.
 
template<typename T>
PromiseResult< T > fl::task::await (Promise< T > p, fl::u32 timeout_ms=fl::platforms::kAwaitDefaultTimeoutMs) FL_NO_EXCEPT
 Await promise completion in a coroutine (Trampoline to platform implementation)
 
int & fl::task::detail::await_depth_tls () FL_NO_EXCEPT
 Get reference to thread-local await recursion depth.
 
template<typename T>
PromiseResult< T > fl::task::await_top_level (Promise< T > p) FL_NO_EXCEPT
 Synchronously wait for a promise to complete (ONLY safe in top-level contexts)
 
bool fl::task::has_tasks () FL_NO_EXCEPT
 Check if any systems have active tasks.
 
bool fl::task::operator& (ExecFlags a, ExecFlags b) FL_NO_EXCEPT
 
ExecFlags fl::task::operator| (ExecFlags a, ExecFlags b) FL_NO_EXCEPT
 
void fl::task::run (fl::u32 microseconds=1000, ExecFlags flags=ExecFlags::ALL) FL_NO_EXCEPT
 Run selected task subsystems.
 
void fl::task::yield_system (fl::u32 microseconds) FL_NO_EXCEPT
 OS-level yield only: same behavior as run(us, ExecFlags::SYSTEM).