2022-06-11 23:01:27 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2022-12-17 20:14:19 +00:00
|
|
|
File: AuIOWaitableIOTimer.cpp
|
2022-06-11 23:01:27 +00:00
|
|
|
Date: 2022-6-6
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#include <Source/RuntimeInternal.hpp>
|
|
|
|
#include <Aurora/IO/IOExperimental.hpp>
|
2022-12-17 20:14:19 +00:00
|
|
|
#include "AuIOWaitableIOTimer.hpp"
|
2022-06-11 23:01:27 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-06-28 14:57:29 +00:00
|
|
|
AuUInt32 IOWaitableIOTimer::IOTimeoutInMS()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-06-11 23:01:27 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|