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

Function pollUntil

tests/fl/stl/asio/http/native_client.cpp:77–83  ·  view source on GitHub ↗

Poll a condition with sleep between attempts. Loopback TCP is fast but accept/recv may not be ready immediately, especially under heavy load.

Source from the content-addressed store, hash-verified

75// Poll a condition with sleep between attempts. Loopback TCP is fast but
76// accept/recv may not be ready immediately, especially under heavy load.
77static bool pollUntil(fl::function<bool()> pred, int maxAttempts = 100) {
78 for (int i = 0; i < maxAttempts; ++i) {
79 if (pred()) return true;
80 fl::this_thread::sleep_for(fl::chrono::milliseconds(10)); // ok sleep for
81 }
82 return false;
83}
84
85// =============================================================================
86// Pure state-machine tests (no TCP connections needed)

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 1

sleep_forFunction · 0.50

Tested by

no test coverage detected