Replace float/UInt64 durations by a more precise Time class (#388)
Improve Clock class with atomic RestartIfOver method and allows to choose required precision
This commit is contained in:
31
src/Nazara/Core/Posix/TimeImpl.cpp
Normal file
31
src/Nazara/Core/Posix/TimeImpl.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Posix/TimeImpl.hpp>
|
||||
#include <time.h>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
bool InitializeHighPrecisionTimer()
|
||||
{
|
||||
return true; //< No initialization required
|
||||
}
|
||||
|
||||
Time GetElapsedNanosecondsImpl()
|
||||
{
|
||||
timespec time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
|
||||
return Time::Seconds(time.tv_sec) + Time::Nanoseconds(time.tv_nsec);
|
||||
}
|
||||
|
||||
Time GetElapsedMillisecondsImpl()
|
||||
{
|
||||
timespec time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
|
||||
return Time::Seconds(time.tv_sec) + Time::Nanoseconds(time.tv_nsec);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user