FastLED 3.9.15
Loading...
Searching...
No Matches

◆ await()

template<typename T>
PromiseResult< T > fl::task::await ( Promise< T > p)
inline

Await promise completion in a coroutine (Trampoline to platform implementation)

Template Parameters
TThe type of value the promise resolves to
Parameters
pThe promise to await
Returns
A PromiseResult<T> containing either the resolved value or an error

This is the public API for awaiting promises in coroutines. It delegates to the platform-specific implementation in fl::platforms::await().

REQUIREMENTS:

  • MUST be called from within a fl::task::coroutine() context
  • Only available on ESP32 (FreeRTOS) and Host/Stub (std::thread) platforms
  • Promise MUST eventually complete (or timeout)

SAFETY: Unlike await_top_level(), this does NOT busy-wait. The coroutine is suspended by the OS scheduler and wakes when the promise completes, with zero CPU overhead.

Examples

.func = []() {
auto result = fl::task::await(fl::fetch_get("http://example.com"));
if (result.ok()) {
process(result.value());
}
}
});
Handle coroutine(const CoroutineConfig &config)
Definition task.cpp.hpp:364
PromiseResult< T > await(Promise< T > p)
Await promise completion in a coroutine (Trampoline to platform implementation)
Definition executor.h:305
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

Definition at line 305 of file executor.h.

305 {
306 return fl::platforms::await(p);
307}

Referenced by AutoResearchRemoteControl::registerFunctions().

+ Here is the caller graph for this function: