[*] Fix more scuffed time logic

This commit is contained in:
Reece Wilson 2022-01-21 19:36:56 +00:00
parent 5cba5f7b16
commit 66870a0f1a
2 changed files with 21 additions and 7 deletions

View File

@ -36,6 +36,8 @@ namespace Aurora::Threading
{
annoying_->Lock();
}
constructed_ = true;
}
LockGuard(T &&lock)
@ -57,10 +59,17 @@ namespace Aurora::Threading
{
annoying_->Lock();
}
constructed_ = true;
}
~LockGuard()
{
if (!constructed_)
{
return;
}
if constexpr (AuIsBaseOfTemplate<AURORA_RUNTIME_AU_SHARED_PTR, Internal_t>::value || AuIsBaseOfTemplate<AURORA_RUNTIME_AU_UNIQUE_PTR, Internal_t>::value)
{
annoying_->get()->Unlock();
@ -73,6 +82,7 @@ namespace Aurora::Threading
private:
AuConditional_t<AuIsPointer_v<T>, T, T*> annoying_;
bool constructed_ {};
};
#define AU_LOCK_GUARD(variable) Aurora::Threading::LockGuard<decltype(variable)> AU_CONCAT(__stack_lock, __COUNTER__) (variable);

View File

@ -19,28 +19,32 @@ namespace Aurora::Time
{
return AuToString(ms) + "ms";
}
else if (ms >= 1000)
else if (ms < (1000 * 60))
{
auto s = msDiv1000;
auto remMs = ms % 1000;
return AuToString(s) + "." + AuToString(remMs) + "s";
}
else if (ms > (1000 * 60))
else if (ms < (1000 * 60 * 60))
{
auto m = msDiv1000Div60;
auto remS = msDiv1000Mod60;
return AuToString(m) + "m " + AuToString(remS) + "s";
}
else if (ms > (1000 * 60 * 60))
else if (ms < (1000 * 60 * 60 * 24))
{
auto h = msDiv1000Div60 / 60;
auto remM = msDiv1000Div60 % 60;
auto h = msDiv1000Div60 / 60;
auto remM = msDiv1000Div60;
auto remS = msDiv1000Mod60;
return AuToString(h) + "h " + AuToString(remM) + "m" + AuToString(remS) + "s";
return AuToString(h) + "h " + AuToString(remM) + "m " + AuToString(remS) + "s";
}
else
{
return AuToString(ms); // ?
auto d = (msDiv1000Div60 / 60 / 24);
auto h = (msDiv1000Div60 / 60) - (d * 24);
auto remM = msDiv1000Div60;
auto remS = msDiv1000Mod60;
return AuToString(d) + "d " + AuToString(h) + "h " + AuToString(remM) + "m " + AuToString(remS) + "s";
}
}
}