FastLED 3.9.15
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 integrates with FastLED's engine events and can be pumped during delay() calls on WASM platforms for optimal responsiveness.

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();
// Now your tasks will be automatically updated during:
// - FastLED.show() calls (via engine events)
// - delay() calls on WASM platforms
// - Manual fl::task::run() calls
}
void setup()
void register_runner(Runner *r)
Register a runner.
static Executor & instance()
virtual void update()=0
Update this runner (called during task pumping)
virtual size_t active_task_count() const =0
Get number of active tasks (for debugging/monitoring)
virtual bool has_active_tasks() const =0
Check if this runner has active tasks.
Generic task runner interface.
Definition executor.h:88
Task executor — runs registered task runners and manages the run loop.

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