AuroraRuntime/Source/IO/AuIOWaitableIOTimer.cpp
J Reece Wilson 35761edaec [+] AuIO::Loop::NewLSTimerHighResolution
[*] ILSTimer::UpdateTime -> ILSTimer::UpdateTimeWall
[*] ILSTimer::UpdateTimeNs -> ILSTimer::UpdateTimeWallNs
[+] ILSTimer::UpdateTimeSteady
[+] ILSTimer::UpdateTimeSteadyNs
2024-09-08 07:26:23 +01:00

109 lines
2.2 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuIOWaitableIOTimer.cpp
Date: 2022-6-6
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include <Aurora/IO/IOExperimental.hpp>
#include "AuIOWaitableIOTimer.hpp"
namespace Aurora::IO
{
IOWaitableIOTimer::IOWaitableIOTimer()
{
}
bool IOWaitableIOTimer::IsValid()
{
return bool(this->source);
}
bool IOWaitableIOTimer::IsRunOnOtherTick()
{
return {};
}
bool IOWaitableIOTimer::IsRunOnTick()
{
return {};
}
bool IOWaitableIOTimer::CanRequestTick()
{
return {};
}
void IOWaitableIOTimer::OnReportPumper(const AuSPtr<IIOProcessorManualInvoker> &iface)
{
}
bool IOWaitableIOTimer::IsRunOnSelfIO()
{
return true;
}
AuSPtr<Loop::ILoopSource> IOWaitableIOTimer::GetSelfIOSource()
{
return this->source;
}
bool IOWaitableIOTimer::IsRunOnSelfIOCheckedOnTimerTick()
{
return true;
}
bool IOWaitableIOTimer::ApplyRateLimit()
{
return false;
}
AuUInt32 IOWaitableIOTimer::IOTimeoutInMS()
{
return 0;
}
AuUInt64 IOWaitableIOTimer::SetConstantTick(AuUInt64 ns)
{
auto old = AuExchange(this->constantTickNs, ns);
this->source->UpdateTickRateIfAnyNs(ns);
return old;
}
AuUInt64 IOWaitableIOTimer::SetTargetTimeAbs(AuUInt64 ns)
{
auto old = AuExchange(this->targetTimeAbsNs, ns);
this->source->UpdateTimeSteadyNs(ns);
return old;
}
AUKN_SYM AuSPtr<IIOWaitableIOTimer> NewWaitableIOTimer()
{
auto timer = AuMakeShared<IOWaitableIOTimer>();
if (!timer)
{
SysPushErrorMem();
return {};
}
if (gRuntimeConfig.ioConfig.bUseHighResTimerUnderIOWaitableTimer)
{
timer->source = AuLoop::NewLSTimerHighResolution(0);
}
else
{
timer->source = AuLoop::NewLSTimer(0);
}
if (!timer->IsValid())
{
SysPushErrorMem();
return {};
}
return timer;
}
}