This commit is contained in:
jeanlemotan
2024-07-02 18:06:33 +02:00
commit 8297b0b45f
157 changed files with 24865 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
#pragma once
#include "tl/detail/prologue.h"
#include <EASTL/chrono.h>
namespace tl
{
using namespace eastl;
namespace chrono
{
using namespace eastl::chrono;
template <typename Clock>
class TL_API chrono final
{
public:
//! Reset the internal time stamp. If you specify an elapsed time offset it will affect directly to getElapsed.
void reset(typename Clock::duration elapsed_offset = Clock::duration::zero()) noexcept
{
m_start_time_point = Clock::now() + elapsed_offset;
}
//! Return the time passed between the last Reset call and now.
typename Clock::duration get_elapsed() const noexcept
{
return Clock::now() - m_start_time_point;
}
//! Return the time passed between the last Reset call and now and then Reset the Clock.
typename Clock::duration get_elapsed_and_reset() noexcept
{
auto now = Clock::now();
auto d = now - m_start_time_point;
m_start_time_point = now;
return d;
}
private:
typename Clock::time_point m_start_time_point = Clock::now();
};
using system_chrono = chrono<eastl::chrono::system_clock>;
using high_resolution_chrono = chrono<eastl::chrono::high_resolution_clock>;
}
}