FastLED 3.10.9
Loading...
Searching...
No Matches
driver_completion_wait.cpp.hpp
Go to the documentation of this file.
1// IWYU pragma: private
2
4#include "fl/stl/chrono.h"
5#include "fl/stl/singleton.h"
6
7namespace fl {
8namespace detail {
9
10namespace {
15} // namespace
16
19 const auto previous = hooks.managed;
20 hooks.managed = wait;
21 return previous;
22}
23
26 const auto previous = hooks.legacy;
27 hooks.legacy = wait;
28 return previous;
29}
30
32 // Snapshot hooks: each singleton registers before accepting submissions.
33 // No backend symbol is referenced from this dispatch implementation.
35 const u32 started = millis();
36 if (hooks.managed && !hooks.managed(timeoutMs)) {
37 return false;
38 }
39 if (!hooks.legacy) {
40 return true;
41 }
42 if (timeoutMs == 0) {
43 return hooks.legacy(0);
44 }
45 const u32 elapsed = millis() - started;
46 if (elapsed >= timeoutMs) {
47 // Never pass zero: the public contract interprets it as infinity.
48 return false;
49 }
50 return hooks.legacy(timeoutMs - elapsed);
51}
52
53} // namespace detail
54} // namespace fl
FastLED chrono implementation - duration types for time measurements.
static T & instance() FL_NO_EXCEPT
Definition singleton.h:41
bool(*)(u32 timeoutMs) DriverCompletionWait
Optional completion consumers.
DriverCompletionWait setManagedCompletionWait(DriverCompletionWait wait) FL_NO_EXCEPT
Internal singleton hooks; return the previous hook to allow scoped tests.
DriverCompletionWait setLegacyCompletionWait(DriverCompletionWait wait) FL_NO_EXCEPT
bool waitForDriverCompletion(u32 timeoutMs) FL_NO_EXCEPT
Wait for installed consumers using one deadline (zero means indefinitely).
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_info.h:57
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
Base definition for an LED controller.