AntiCheat refactoring part 7
?
This commit is contained in:
17
src/Utils/Time.cpp
Normal file
17
src/Utils/Time.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace Time
|
||||
{
|
||||
void Interval::Set()
|
||||
{
|
||||
this->LastPoint = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
bool Interval::Elapsed(std::chrono::nanoseconds nsecs)
|
||||
{
|
||||
return ((std::chrono::high_resolution_clock::now() - this->LastPoint) >= nsecs);
|
||||
}
|
||||
}
|
||||
}
|
17
src/Utils/Time.hpp
Normal file
17
src/Utils/Time.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Utils
|
||||
{
|
||||
namespace Time
|
||||
{
|
||||
class Interval
|
||||
{
|
||||
private:
|
||||
std::chrono::high_resolution_clock::time_point LastPoint;
|
||||
|
||||
public:
|
||||
Interval() : LastPoint(std::chrono::high_resolution_clock::now()) {}
|
||||
|
||||
void Set();
|
||||
bool Elapsed(std::chrono::nanoseconds nsecs);
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user