AuroraRuntime/Source/IO/AuIOWaitableIOTimer.cpp
Reece 4e6f116925 [*] Refactor
[+] IProcessSectionView::GetStart
[+] IProcessSectionView::GetEnd
2022-12-17 20:14:19 +00:00

102 lines
2.0 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->UpdateTimeNs(ns);
return old;
}
AUKN_SYM AuSPtr<IIOWaitableIOTimer> NewWaitableIOTimer()
{
auto timer = AuMakeShared<IOWaitableIOTimer>();
if (!timer)
{
SysPushErrorMem();
return {};
}
timer->source = AuLoop::NewLSTimer(0);
if (!timer->IsValid())
{
SysPushErrorMem();
return {};
}
return timer;
}
}