* @brief Blocks the worker thread for the given time (capped at one hour), sleeping in slices * so shutdown can interrupt the wait, then defers the watchdog deadline. */
| 297 | * so shutdown can interrupt the wait, then defers the watchdog deadline. |
| 298 | */ |
| 299 | void DataModel::ControlApiBridge::delay(int milliseconds) |
| 300 | { |
| 301 | const int total = qBound(0, milliseconds, kMaxDelayMs); |
| 302 | for (int slept = 0; slept < total; slept += kDelaySliceMs) { |
| 303 | if (s_shutdownRequested.load(std::memory_order_acquire)) |
| 304 | return; |
| 305 | |
| 306 | QThread::msleep(static_cast<unsigned long>(qMin(kDelaySliceMs, total - slept))); |
| 307 | } |
| 308 | |
| 309 | if (m_watchdog) |
| 310 | m_watchdog->arm(); |
| 311 | } |
| 312 | |
| 313 | //-------------------------------------------------------------------------------------------------- |
| 314 | // Construction |