mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-18 09:25:33 +00:00
Add CInfiniteLoopDetector to detect infinite loops in release builds
This commit is contained in:
20
Runtime/CInfiniteLoopDetector.hpp
Normal file
20
Runtime/CInfiniteLoopDetector.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <future>
|
||||
|
||||
namespace metaforce {
|
||||
class CInfiniteLoopDetector {
|
||||
int m_duration = 0;
|
||||
std::mutex m_mutex;
|
||||
std::promise<void> m_stopRequested;
|
||||
std::future<void> m_futureObj;
|
||||
bool stopRequested() const;
|
||||
public:
|
||||
explicit CInfiniteLoopDetector(int duration=1000);
|
||||
void run();
|
||||
void stop();
|
||||
static void UpdateWatchDog(std::chrono::system_clock::time_point WatchDog);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user