| 152 | } // namespace platforms |
| 153 | |
| 154 | ScopedWatchdog::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 | |
| 180 | ScopedWatchdog::~ScopedWatchdog() FL_NOEXCEPT { |
| 181 | int& count = platforms::scopedWatchdogActiveCount(); |
nothing calls this directly
no test coverage detected