/*** Copyright (C) 2021-2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved. File: LSTimer.cpp Date: 2021-10-1 - 2024-09-08 Author: Reece ***/ #include namespace Aurora::IO::Loop { AuSPtr NewLSTimerOS(AuUInt64 qwAbsStartTimeMs, AuUInt32 dwReschedStepMsOrZero, AuUInt32 dwMaxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady); AuSPtr NewLSTimerIP(AuUInt64 qwAbsStartTimeMs, AuUInt32 dwReschedStepMsOrZero, AuUInt32 dwMaxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady); #if defined(AURORA_IS_MODERNNT_DERIVED) AuSPtr NewLSTimerOSHiRes(AuUInt64 absStartTimeMs, AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady); #endif static bool MustUseAltTimer() { return gRuntimeConfig.ioConfig.bForceAltOSTimerPrimitives; } static bool IsHPInProcess() { #if defined(AURORA_IS_MODERNNT_DERIVED) return true; #else return !gRuntimeConfig.ioConfig.bTrustOSTimerPrimitiveIfKnownGood; #endif } AUKN_SYM AuSPtr NewLSTimerHighResolution(AuUInt64 qwAbsStartTimeMs, AuUInt32 dwReschedStepMsOrZero, AuUInt32 dwMaxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady) { #if defined(AURORA_IS_MODERNNT_DERIVED) if (auto pHighResIO = NewLSTimerOSHiRes(qwAbsStartTimeMs, dwReschedStepMsOrZero, dwMaxIterationsOrZero, bSingleshot, bIsStartTimeSteady)) { return pHighResIO; } #endif if (IsHPInProcess()) { return NewLSTimerIP(qwAbsStartTimeMs, dwReschedStepMsOrZero, dwMaxIterationsOrZero, bSingleshot, bIsStartTimeSteady); } else { return NewLSTimerOS(qwAbsStartTimeMs, dwReschedStepMsOrZero, dwMaxIterationsOrZero, bSingleshot, bIsStartTimeSteady); } } AUKN_SYM AuSPtr NewLSTimer(AuUInt64 qwAbsStartTimeMs, AuUInt32 dwReschedStepMsOrZero, AuUInt32 dwMaxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady) { if (MustUseAltTimer()) { return NewLSTimerIP(qwAbsStartTimeMs, dwReschedStepMsOrZero, dwMaxIterationsOrZero, bSingleshot, bIsStartTimeSteady); } else { return NewLSTimerOS(qwAbsStartTimeMs, dwReschedStepMsOrZero, dwMaxIterationsOrZero, bSingleshot, bIsStartTimeSteady); } } }