FastLED 3.9.15
Loading...
Searching...
No Matches
async.h File Reference

Detailed Description

Generic asynchronous task management for FastLED.

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

The async system integrates with FastLED's engine events and can be pumped during delay() calls on WASM platforms for optimal responsiveness.

Usage

#include "fl/async.h"
// Create a custom async runner
class Myasync_runner : public fl::async_runner {
public:
void update() override {
// Process your async 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() {
Myasync_runner* runner = new Myasync_runner();
// Now your async tasks will be automatically updated during:
// - FastLED.show() calls (via engine events)
// - delay() calls on WASM platforms
// - Manual fl::async_run() calls
}
void setup()
static AsyncManager & instance()
Definition async.cpp:16
void register_runner(async_runner *runner)
Register an async runner.
Definition async.cpp:20
virtual bool has_active_tasks() const =0
Check if this runner has active tasks.
virtual size_t active_task_count() const =0
Get number of active tasks (for debugging/monitoring)
virtual void update()=0
Update this async runner (called during async pumping)
Generic asynchronous task runner interface.
Definition async.h:64
Generic asynchronous task management for FastLED.

Definition in file async.h.

#include "fl/namespace.h"
#include "fl/vector.h"
#include "fl/function.h"
#include "fl/ptr.h"
#include "fl/variant.h"
#include "fl/promise.h"
#include "fl/promise_result.h"
#include "fl/singleton.h"
#include "fl/thread_local.h"
#include "fl/task.h"
#include "fl/time.h"
+ Include dependency graph for async.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  fl::async_runner
 Generic asynchronous task runner interface. More...
 
class  fl::AsyncManager
 Async task manager (singleton) More...
 
class  fl::Scheduler
 

Namespaces

namespace  fl
 IMPORTANT!
 

Functions

size_t fl::async_active_tasks ()
 Get the number of active async tasks across all systems.
 
bool fl::async_has_tasks ()
 Check if any async systems have active tasks.
 
void fl::async_run ()
 Run all registered async tasks once.
 
void fl::async_yield ()
 Platform-specific async yield function.
 
template<typename T>
fl::result< T > fl::await_top_level (fl::promise< T > promise)
 Synchronously wait for a promise to complete (ONLY safe in top-level contexts)