/*** Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: AuIOWaitableIOTimer.cpp Date: 2022-6-6 Author: Reece ***/ #include #include #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 &iface) { } bool IOWaitableIOTimer::IsRunOnSelfIO() { return true; } AuSPtr 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 NewWaitableIOTimer() { auto timer = AuMakeShared(); if (!timer) { SysPushErrorMem(); return {}; } timer->source = AuLoop::NewLSTimer(0); if (!timer->IsValid()) { SysPushErrorMem(); return {}; } return timer; } }