#include #ifdef STA_TACOS_WATCHDOG_ENABLED #include namespace sta { namespace tacos { void Watchdog::func() { for (std::shared_ptr thread : Statemachine::instance()->getActiveThreads()) { switch (thread->getStatus()) { case ThreadStatus::UNKNOWN: // Restart the thread. thread->kill(); thread->start(); restarts_++; break; case ThreadStatus::RUNNING: // Set the thread's status back to UNKNOWN. thread->resetStatus(); break; default: break; } } sleep(STA_TACOS_WATCHDOG_FREQUENCY); } uint16_t Watchdog::getNumRestarts() { return restarts_; } Watchdog::Watchdog() : TacosThread{"Watchdog", STA_TACOS_WATCHDOG_PRIORITY}, restarts_{ 0 } {} Watchdog* Watchdog::_instance = nullptr; } // namespace tacos } // namespace sta #endif // STA_TACOS_WATCHDOG_ENABLED