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

Method ScopedWatchdog

src/fl/wdt/watchdog.cpp.hpp:154–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152} // namespace platforms
153
154ScopedWatchdog::ScopedWatchdog(fl::u32 timeout_ms) FL_NOEXCEPT {
155 static bool sInitialized = false;
156 if (!sInitialized) {
157 sInitialized = true;
158 platforms::scopedWatchdogFirstInit(timeout_ms);
159 }
160
161 // Single-instance enforcement. A second simultaneously-alive ScopedWatchdog
162 // is almost always a bug — the timeout argument here was silently ignored
163 // (only the first instance gets to arm the WDT). Warn once per process so
164 // the developer notices, but still feed so the program survives.
165 int& count = platforms::scopedWatchdogActiveCount();
166 if (count >= 1) {
167 static bool sWarnedOnce = false;
168 if (!sWarnedOnce) {
169 sWarnedOnce = true;
170 platforms::scopedWatchdogPrintLine(fl::string_view(
171 "[FastLED.watchdog] WARN: nested FL_WATCHDOG_AUTO() detected — "
172 "only one scoped guard should be alive at a time"));
173 }
174 }
175 ++count;
176
177 Watchdog::instance().feed();
178}
179
180ScopedWatchdog::~ScopedWatchdog() FL_NOEXCEPT {
181 int& count = platforms::scopedWatchdogActiveCount();

Callers

nothing calls this directly

Calls 4

scopedWatchdogFirstInitFunction · 0.85
scopedWatchdogPrintLineFunction · 0.85
string_viewClass · 0.50
feedMethod · 0.45

Tested by

no test coverage detected