MCPcopy Create free account
hub / github.com/FastLED/FastLED / delayed_reject

Function delayed_reject

tests/fl/task/executor.cpp:629–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627// Helper: Create a promise that rejects after a delay
628template<typename T>
629fl::task::Promise<T> delayed_reject(const fl::task::Error& error, uint32_t delay_ms) {
630 auto p = fl::task::Promise<T>::create();
631
632 fl::thread t([p, error, delay_ms]() mutable {
633 for (uint32_t elapsed = 0; elapsed < delay_ms && !fl::platforms::ICoroutineRuntime::instance().isShutdownRequested(); elapsed += 1) {
634 uint32_t sleep_time = fl::min(1u, delay_ms - elapsed);
635 fl::this_thread::sleep_for(fl::chrono::milliseconds(sleep_time)); // ok sleep for
636 }
637 p.complete_with_error(error);
638 });
639
640 fl::platforms::register_background_thread(fl::move(t));
641 return p;
642}
643
644FL_TEST_CASE("await in coroutine - basic resolution") {
645 fl::atomic<bool> test_completed(false);

Callers

nothing calls this directly

Calls 4

createFunction · 0.85
isShutdownRequestedMethod · 0.80
complete_with_errorMethod · 0.80
sleep_forFunction · 0.50

Tested by

no test coverage detected