1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2 
3 #ifndef _WATCHDOG_H
4 #define _WATCHDOG_H
5 
6 #include <string>
7 #include "System/Platform/Threading.h"
8 
9 // Update Watchdog::threadNames also if adding threads
10 enum WatchdogThreadnum {
11 	WDT_MAIN  = 0,
12 	WDT_SIM   = 1,
13 	WDT_LOAD  = 2,
14 	WDT_AUDIO = 3,
15 	WDT_COUNT = 4,
16 };
17 
18 namespace Watchdog
19 {
20 	//! Installs the watchdog thread
21 	void Install();
22 	void Uninstall();
23 
24 	//! Call this to reset the watchdog timer of the current thread
25 	void ClearTimer(bool disable = false, Threading::NativeThreadId* _threadId = NULL);
26 	void ClearTimer(const WatchdogThreadnum num, bool disable = false);
27 	void ClearTimer(const std::string& name, bool disable = false);
28 	inline void ClearTimer(const char* name, bool disable = false) {
29 		ClearTimer(std::string(name), disable);
30 	}
31 	void ClearPrimaryTimers(bool disable = false);
32 
33 	//! Call these in the threads you want to monitor
34 	void RegisterThread(WatchdogThreadnum num, bool primary = false);
35 	void DeregisterThread(WatchdogThreadnum num);
36 }
37 
38 #endif // _WATCHDOG_H
39