Compare commits
2 Commits
e62a99777f
...
6852fbddf1
Author | SHA1 | Date | |
---|---|---|---|
6852fbddf1 | |||
ffb1cbb09b |
@ -237,12 +237,29 @@ namespace Aurora::Memory
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class Z>
|
||||
bool operator==(const Aurora::Memory::PmrCppHeapWrapper<Z> &rhs) noexcept
|
||||
{
|
||||
return this->GetHeapRaw() == rhs.GetHeapRaw();
|
||||
}
|
||||
|
||||
template <class Z>
|
||||
bool operator!=(const Aurora::Memory::PmrCppHeapWrapper<Z> &rhs) noexcept
|
||||
{
|
||||
return this->GetHeapRaw() == rhs.GetHeapRaw();
|
||||
}
|
||||
template <class Z>
|
||||
bool operator==(const Aurora::Memory::CppHeapWrapper<Z> &rhs) noexcept
|
||||
{
|
||||
return this->GetHeapRaw() == rhs.GetHeapRaw();
|
||||
}
|
||||
|
||||
template <class Z>
|
||||
bool operator!=(const Aurora::Memory::CppHeapWrapper<Z> &rhs) noexcept
|
||||
{
|
||||
return this->GetHeapRaw() == rhs.GetHeapRaw();
|
||||
}
|
||||
|
||||
private:
|
||||
#if defined(AU_NO_COMPRESS_CPPHEAP_WRAPPER)
|
||||
mutable std::shared_ptr<void> spHeap;
|
||||
@ -251,6 +268,8 @@ namespace Aurora::Memory
|
||||
mutable std::shared_ptr<Heap> spHeap;
|
||||
#endif
|
||||
|
||||
template <typename Z>
|
||||
friend struct PmrCppHeapWrapper;
|
||||
friend struct detail::AccessorICantEven;
|
||||
};
|
||||
|
||||
@ -563,6 +582,8 @@ namespace Aurora::Memory
|
||||
mutable CppHeapWrapper *pFuckCppRetardsFixYourWorthlessSpec {};
|
||||
mutable CppHeapWrapper *pFuckCppRetardsFixYourWorthlessSpec2 {};
|
||||
|
||||
template <typename Z>
|
||||
friend struct CppHeapWrapper;
|
||||
friend struct detail::AccessorICantEven;
|
||||
};
|
||||
}
|
||||
@ -580,3 +601,16 @@ inline bool operator==(const Aurora::Memory::PmrCppHeapWrapper<T> &lhs,
|
||||
{
|
||||
return lhs.GetHeapRaw() == rhs.GetHeapRaw();
|
||||
}
|
||||
template <class T, class Z>
|
||||
inline bool operator!=(const Aurora::Memory::CppHeapWrapper<T> &lhs,
|
||||
const Aurora::Memory::CppHeapWrapper<Z> &rhs) noexcept
|
||||
{
|
||||
return lhs.GetHeapRaw() != rhs.GetHeapRaw();
|
||||
}
|
||||
|
||||
template <class T, class Z>
|
||||
inline bool operator!=(const Aurora::Memory::PmrCppHeapWrapper<T> &lhs,
|
||||
const Aurora::Memory::PmrCppHeapWrapper<Z> &rhs) noexcept
|
||||
{
|
||||
return lhs.GetHeapRaw() != rhs.GetHeapRaw();
|
||||
}
|
@ -40,6 +40,8 @@ namespace Aurora::Async
|
||||
static AuUInt64 uNextSysTickGuessed {};
|
||||
static AuUInt64 uNextWakeuptimeRateLimit {};
|
||||
static AuBST<AuUInt64, SchedEntry> gOrderedEntries;
|
||||
static AuUInt32 uScheduledHighPerfTimers {};
|
||||
|
||||
// prevents stupid tick issues
|
||||
static bool gLockedPump = false;
|
||||
|
||||
@ -146,16 +148,70 @@ namespace Aurora::Async
|
||||
uNextSysTickGuessed = 0;
|
||||
|
||||
#if !defined(SCHEDULER_USE_NO_SPIN)
|
||||
gSchedCondvar->WaitForSignalNS(uNextTick - uNow);
|
||||
|
||||
auto uNS = uNextTick - uNow;
|
||||
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
bool bExpensivePath = AuAtomicLoad(&uScheduledHighPerfTimers);
|
||||
bool bWin10sABinch {};
|
||||
|
||||
if (!AuSwInfo::IsWindows8Point1OrGreater())
|
||||
{
|
||||
if (gRuntimeConfig.threadingConfig.bEnableAggressiveScheduling)
|
||||
{
|
||||
if (uNS <= AuMSToNS<AuUInt64>(3))
|
||||
{
|
||||
bExpensivePath = true;
|
||||
}
|
||||
else if (uNS < AuMSToNS<AuUInt64>(1'000) &&
|
||||
uNS > AuMSToNS<AuUInt64>(100) &&
|
||||
!bExpensivePath)
|
||||
{
|
||||
// Windows 7 coalescing doesnt batch very well.
|
||||
// We overshoot by ~6MS or 8MS, if we're above ~20MS
|
||||
uNS -= AuMSToNS<AuUInt64>(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Windows 10-11 will coalesce us less, but our precision is an order of mangitude worse than what I can get out of Windows 7
|
||||
if (bExpensivePath)
|
||||
{
|
||||
bWin10sABinch = true;
|
||||
bExpensivePath = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bExpensivePath)
|
||||
{
|
||||
// With any luck, we'll be scheduled within 0.02MS of error with some spikes to .3MS.
|
||||
gSchedLock->Unlock();
|
||||
AuThreading::SleepNs(uNS);
|
||||
gSchedLock->Lock();
|
||||
}
|
||||
else if (bWin10sABinch)
|
||||
{
|
||||
// With any luck, we'll be scheduled within 0.3MS of error, maybe a little bit lower for some fraction of a MS requests.
|
||||
Win32DropSchedulerResolutionForced();
|
||||
gSchedCondvar->WaitForSignalNS(uNS);
|
||||
Win32DropSchedulerResolutionForcedUndo();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
gSchedCondvar->WaitForSignalNS(uNS);
|
||||
}
|
||||
|
||||
#else
|
||||
gSchedCondvar.WaitForSignalNsEx(&AuStaticCast<AuThreadPrimitives::ConditionMutexImpl>(gSchedLock.AsPointer())->mutex, uNextTick - uNow, false);
|
||||
#endif
|
||||
}
|
||||
else if (uNow >= uNextTick)
|
||||
else if (uNow >= uNextTick && uNextSysTickGuessed != 0)
|
||||
{
|
||||
uNextSysTickGuessed = 0;
|
||||
}
|
||||
else if (uNextSysTickGuessed == 0)
|
||||
else if (uNextSysTickGuessed == 0 && gOrderedEntries.empty())
|
||||
{
|
||||
#if !defined(SCHEDULER_USE_NO_SPIN)
|
||||
gSchedCondvar->WaitForSignalNS(gRuntimeConfig.async.bEnableLegacyTicks ?
|
||||
@ -190,6 +246,7 @@ namespace Aurora::Async
|
||||
{
|
||||
// IO timer hack!
|
||||
entry.runnable->RunAsync();
|
||||
AuAtomicSub(&uScheduledHighPerfTimers, 1u);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
@ -293,6 +350,10 @@ namespace Aurora::Async
|
||||
{
|
||||
AuAtomicAdd(&pool->uAtomicCounter, 1u);
|
||||
}
|
||||
else
|
||||
{
|
||||
AuAtomicAdd(&uScheduledHighPerfTimers, 1u);
|
||||
}
|
||||
SchedNextTime(ns);
|
||||
return AuTryInsert(gOrderedEntries,
|
||||
AuConstReference(ns),
|
||||
|
@ -38,7 +38,9 @@ namespace Aurora::Memory
|
||||
|
||||
namespace Aurora
|
||||
{
|
||||
static bool gShouldResPathDoNothing {};
|
||||
static bool gShouldResPathDoNothing {}; // always
|
||||
static bool gShouldResPathDoNothing2 {}; // win11 singleshot
|
||||
static ULONG gLastActualResolution {};
|
||||
|
||||
#if !defined(AURORA_PLATFORM_WIN32)
|
||||
HMODULE UWPLibraryW(LPCWSTR lpLibFileName);
|
||||
@ -264,6 +266,7 @@ namespace Aurora
|
||||
ADD_GET_PROC(Nt, RtlWakeByAddressAll)
|
||||
ADD_GET_PROC(Nt, RtlWakeAddressSingle)
|
||||
ADD_GET_PROC(Nt, ZwSetTimerResolution)
|
||||
ADD_GET_PROC(Nt, ZwQueryTimerResolution)
|
||||
ADD_GET_PROC(Nt, NtQueryInformationProcess)
|
||||
ADD_GET_PROC(Nt, NtNotifyChangeDirectoryFile)
|
||||
ADD_GET_PROC(Nt, NtTerminateProcess)
|
||||
@ -310,6 +313,7 @@ namespace Aurora
|
||||
ADD_GET_PROC(Kernel32, Module32FirstW)
|
||||
ADD_GET_PROC(Kernel32, Module32NextW)
|
||||
ADD_GET_PROC(Kernel32, CreateJobObjectW)
|
||||
ADD_GET_PROC(Kernel32, CreateWaitableTimerExW)
|
||||
|
||||
ADD_GET_PROC(Kernel32, GetConsoleScreenBufferInfo)
|
||||
ADD_GET_PROC(Kernel32, SetConsoleScreenBufferSize)
|
||||
@ -563,6 +567,8 @@ namespace Aurora
|
||||
return bool(GetEnvironmentVariableW(L"AURORA_IS_NETBOOK", nullptr, 0));
|
||||
}
|
||||
|
||||
void Win32DropSchedulerResolutionNow();
|
||||
|
||||
void Win32DropInit()
|
||||
{
|
||||
gShouldResPathDoNothing =
|
||||
@ -577,6 +583,8 @@ namespace Aurora
|
||||
#endif
|
||||
;
|
||||
|
||||
gShouldResPathDoNothing2 = gShouldResPathDoNothing;
|
||||
|
||||
if (gShouldResPathDoNothing)
|
||||
{
|
||||
return;
|
||||
@ -596,29 +604,98 @@ namespace Aurora
|
||||
powerThrottling.ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED;
|
||||
powerThrottling.StateMask = 0;
|
||||
|
||||
gShouldResPathDoNothing = bool(pSetProcessInformation(GetCurrentProcess(),
|
||||
ProcessPowerThrottling,
|
||||
&powerThrottling,
|
||||
sizeof(powerThrottling)));
|
||||
|
||||
powerThrottling.ControlMask = PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;
|
||||
powerThrottling.StateMask = 0;
|
||||
gShouldResPathDoNothing &= bool(pSetProcessInformation(GetCurrentProcess(),
|
||||
gShouldResPathDoNothing2 = bool(pSetProcessInformation(GetCurrentProcess(),
|
||||
ProcessPowerThrottling,
|
||||
&powerThrottling,
|
||||
sizeof(powerThrottling)));
|
||||
|
||||
powerThrottling.ControlMask = PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;
|
||||
powerThrottling.StateMask = 0;
|
||||
gShouldResPathDoNothing2 &= bool(pSetProcessInformation(GetCurrentProcess(),
|
||||
ProcessPowerThrottling,
|
||||
&powerThrottling,
|
||||
sizeof(powerThrottling)));
|
||||
|
||||
if (!gShouldResPathDoNothing2 &&
|
||||
(AuSWInfo::IsWindows11OrGreater() || AuSwInfo::IsWindows10Milestone20H1OrGreater()))
|
||||
{
|
||||
Win32DropSchedulerResolutionNow();
|
||||
}
|
||||
else
|
||||
{
|
||||
gShouldResPathDoNothing2 = false;
|
||||
}
|
||||
|
||||
AuThreading::InitOnceLocker::Finish(&gInitOnce);
|
||||
} /* else no-wait. intentionally nop*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Win32DropSchedulerResolutionForced()
|
||||
{
|
||||
ULONG ullActualResolution {};
|
||||
|
||||
if (!gShouldResPathDoNothing)
|
||||
{
|
||||
Win32DropSchedulerResolution();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pZwQueryTimerResolution)
|
||||
{
|
||||
static AuInitOnce gInitOnce;
|
||||
gInitOnce.Call([]()
|
||||
{
|
||||
ULONG IDC[2];
|
||||
pZwQueryTimerResolution(&IDC[0], &IDC[1], &gLastActualResolution);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Win32DropSchedulerResolutionNow()
|
||||
{
|
||||
ULONG ullActualResolution {};
|
||||
|
||||
if (!pZwSetTimerResolution)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto uRet = pZwSetTimerResolution(1, true, &ullActualResolution);
|
||||
|
||||
if (uRet == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (uRet == 0xC0000245)
|
||||
{
|
||||
if ((uRet = pZwSetTimerResolution(5'000, true, &ullActualResolution)) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Win32DropSchedulerResolutionForcedUndo()
|
||||
{
|
||||
ULONG ullActualResolution {};
|
||||
|
||||
if (!gShouldResPathDoNothing ||
|
||||
!pZwSetTimerResolution ||
|
||||
!gLastActualResolution)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
(void)pZwSetTimerResolution(gLastActualResolution, true, &ullActualResolution);
|
||||
}
|
||||
|
||||
void Win32DropSchedulerResolution()
|
||||
{
|
||||
ULONG ullActualResolution {};
|
||||
|
||||
if (gShouldResPathDoNothing)
|
||||
if (gShouldResPathDoNothing2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -636,22 +713,7 @@ namespace Aurora
|
||||
}
|
||||
}
|
||||
|
||||
if (pZwSetTimerResolution)
|
||||
{
|
||||
auto uRet = pZwSetTimerResolution(1, true, &ullActualResolution);
|
||||
|
||||
if (uRet == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (uRet == 0xC0000245)
|
||||
{
|
||||
if ((uRet = pZwSetTimerResolution(5'000, true, &ullActualResolution)) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Win32DropSchedulerResolutionNow();
|
||||
}
|
||||
|
||||
HANDLE UWPCreateFileMappingA(HANDLE hFile,
|
||||
|
@ -283,6 +283,13 @@ namespace Aurora
|
||||
SIZE_T dwNumberOfBytesToMap
|
||||
);
|
||||
|
||||
inline HANDLE(__stdcall *pCreateWaitableTimerExW)(
|
||||
LPSECURITY_ATTRIBUTES lpTimerAttributes,
|
||||
LPCWSTR lpTimerName,
|
||||
DWORD dwFlags,
|
||||
DWORD dwDesiredAccess
|
||||
);
|
||||
|
||||
inline NTSTATUS(__stdcall *pNtNotifyChangeDirectoryFile)(
|
||||
HANDLE FileHandle,
|
||||
HANDLE Event,
|
||||
@ -487,6 +494,12 @@ namespace Aurora
|
||||
PULONG ActualResolution
|
||||
);
|
||||
|
||||
inline NTSTATUS(__stdcall *pZwQueryTimerResolution)(
|
||||
PULONG CoarsestResolution,
|
||||
PULONG FinestResolution,
|
||||
PULONG ActualResolution
|
||||
);
|
||||
|
||||
inline BOOLEAN(__stdcall *pRtlGenRandom)(
|
||||
PVOID RandomBuffer,
|
||||
ULONG RandomBufferLength
|
||||
@ -1371,6 +1384,8 @@ namespace Aurora
|
||||
|
||||
void Win32DropInit();
|
||||
void Win32DropSchedulerResolution();
|
||||
void Win32DropSchedulerResolutionForcedUndo();
|
||||
void Win32DropSchedulerResolutionForced();
|
||||
|
||||
void Win32Terminate();
|
||||
|
||||
|
@ -11,13 +11,24 @@
|
||||
|
||||
namespace Aurora::IO::Loop
|
||||
{
|
||||
LSTimer::LSTimer(AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero, bool bSingleshot, HANDLE handle) :
|
||||
static AuUInt32 gHighResTimers {};
|
||||
|
||||
LSTimer::LSTimer(AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero, bool bSingleshot, HANDLE handle, bool bHighRes) :
|
||||
LSHandle(AuReinterpretCast<AuUInt>(handle)),
|
||||
reschedStepNsOrZero_(AuMSToNS<AuUInt64>(reschedStepMsOrZero)),
|
||||
bSingleshot(bSingleshot),
|
||||
maxIterationsOrZero_(maxIterationsOrZero)
|
||||
maxIterationsOrZero_(maxIterationsOrZero),
|
||||
bHighRes_(bHighRes)
|
||||
{
|
||||
this->targetTime_ = AuTime::ConvertTimestamp(AuTime::CurrentClockMS());
|
||||
|
||||
if (this->bHighRes_)
|
||||
{
|
||||
if (AuAtomicAdd(&gHighResTimers, 1u) == 1)
|
||||
{
|
||||
Win32DropSchedulerResolutionForced();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LSTimer::~LSTimer()
|
||||
@ -25,6 +36,14 @@ namespace Aurora::IO::Loop
|
||||
auto handle = AuReinterpretCast<HANDLE>(this->handle);
|
||||
AuWin32CloseHandle(handle);
|
||||
this->handle = kInvalidHandle;
|
||||
|
||||
if (this->bHighRes_)
|
||||
{
|
||||
if (AuAtomicSub(&gHighResTimers, 1u) == 0)
|
||||
{
|
||||
Win32DropSchedulerResolutionForcedUndo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LSTimer::UpdateTimeWall(AuUInt64 absTimeMs)
|
||||
@ -132,9 +151,6 @@ namespace Aurora::IO::Loop
|
||||
|
||||
AuSPtr<ITimer> NewLSTimerOS(AuUInt64 absStartTimeMs, AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady)
|
||||
{
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/threadpoolapiset/nf-threadpoolapiset-setthreadpoolwait
|
||||
// TODO: Is that any better with an event?
|
||||
|
||||
auto handle = CreateWaitableTimerW(nullptr, !bSingleshot, nullptr);
|
||||
if (!handle)
|
||||
{
|
||||
@ -142,7 +158,49 @@ namespace Aurora::IO::Loop
|
||||
return {};
|
||||
}
|
||||
|
||||
auto object = AuMakeShared<LSTimer>(reschedStepMsOrZero, maxIterationsOrZero, bSingleshot, handle);
|
||||
auto object = AuMakeShared<LSTimer>(reschedStepMsOrZero, maxIterationsOrZero, bSingleshot, handle, false);
|
||||
if (!object)
|
||||
{
|
||||
SysPushErrorMem();
|
||||
AuWin32CloseHandle(handle);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (absStartTimeMs)
|
||||
{
|
||||
if (bIsStartTimeSteady)
|
||||
{
|
||||
object->UpdateTimeSteady(absStartTimeMs);
|
||||
}
|
||||
else
|
||||
{
|
||||
object->UpdateTimeWall(absStartTimeMs);
|
||||
}
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
AuSPtr<ITimer> NewLSTimerOSHiRes(AuUInt64 absStartTimeMs, AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady)
|
||||
{
|
||||
if (!AuSWInfo::IsWindows10MilestoneRS4OrGreater())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!pCreateWaitableTimerExW)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto handle = pCreateWaitableTimerExW(nullptr, nullptr, (bSingleshot ? 0 : 1) | CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS);
|
||||
if (!handle)
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return {};
|
||||
}
|
||||
|
||||
auto object = AuMakeShared<LSTimer>(reschedStepMsOrZero, maxIterationsOrZero, bSingleshot, handle, true);
|
||||
if (!object)
|
||||
{
|
||||
SysPushErrorMem();
|
||||
|
@ -12,7 +12,7 @@ namespace Aurora::IO::Loop
|
||||
{
|
||||
struct LSTimer : ITimer, virtual LSHandle
|
||||
{
|
||||
LSTimer(AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero, bool bSingleshot, HANDLE handle);
|
||||
LSTimer(AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero, bool bSingleshot, HANDLE handle, bool bHighRes);
|
||||
~LSTimer();
|
||||
|
||||
PROXY_LOOP_LOOPSOURCE_EXT_APIS_;
|
||||
@ -38,5 +38,6 @@ namespace Aurora::IO::Loop
|
||||
AuUInt64 targetTime_ {0};
|
||||
AuUInt32 count_ {0};
|
||||
bool bSingleshot {};
|
||||
bool bHighRes_ {};
|
||||
};
|
||||
}
|
@ -12,6 +12,10 @@ namespace Aurora::IO::Loop
|
||||
AuSPtr<ITimer> NewLSTimerOS(AuUInt64 qwAbsStartTimeMs, AuUInt32 dwReschedStepMsOrZero, AuUInt32 dwMaxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady);
|
||||
AuSPtr<ITimer> NewLSTimerIP(AuUInt64 qwAbsStartTimeMs, AuUInt32 dwReschedStepMsOrZero, AuUInt32 dwMaxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady);
|
||||
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
AuSPtr<ITimer> NewLSTimerOSHiRes(AuUInt64 absStartTimeMs, AuUInt32 reschedStepMsOrZero, AuUInt32 maxIterationsOrZero, bool bSingleshot, bool bIsStartTimeSteady);
|
||||
#endif
|
||||
|
||||
static bool MustUseAltTimer()
|
||||
{
|
||||
return gRuntimeConfig.ioConfig.bForceAltOSTimerPrimitives;
|
||||
@ -28,6 +32,13 @@ namespace Aurora::IO::Loop
|
||||
|
||||
AUKN_SYM AuSPtr<ITimer> 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);
|
||||
|
@ -84,9 +84,21 @@ namespace Aurora::Threading
|
||||
return;
|
||||
}
|
||||
|
||||
if (qwTimeout < AuMSToNS<AuUInt64>(1))
|
||||
if (qwTimeout > AuMSToNS<AuUInt64>(60))
|
||||
{
|
||||
uEndTimeSteadyNS -= 250'000ull;
|
||||
uEndTimeSteadyNS -= 20'000'000ull;
|
||||
}
|
||||
else if (qwTimeout > AuMSToNS<AuUInt64>(40))
|
||||
{
|
||||
uEndTimeSteadyNS -= 10'000'000ull;
|
||||
}
|
||||
else if (qwTimeout > AuMSToNS<AuUInt64>(10))
|
||||
{
|
||||
uEndTimeSteadyNS -= 4'000'000ull;
|
||||
}
|
||||
else if (qwTimeout < AuMSToNS<AuUInt64>(1'300))
|
||||
{
|
||||
uEndTimeSteadyNS -= 500'000ull;
|
||||
}
|
||||
|
||||
Win32DropSchedulerResolution();
|
||||
@ -95,7 +107,7 @@ namespace Aurora::Threading
|
||||
{
|
||||
if (qwTimeout < AuMSToNS<AuUInt64>(1))
|
||||
{
|
||||
uEndTimeSteadyNS -= 100'000ull;
|
||||
uEndTimeSteadyNS -= 250'000ull;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -109,7 +121,7 @@ namespace Aurora::Threading
|
||||
#else
|
||||
if (AuThreadPrimitives::ThrdCfg::gPlatformIsSMPProcessorOptimized)
|
||||
{
|
||||
if (uEndTimeSteadyNS2 - uNowNS <= 100000ull)
|
||||
if (uEndTimeSteadyNS2 - uNowNS <= 230000ull)
|
||||
{
|
||||
auto uNow = AuAtomicAdd(&AuThreadPrimitives::gSpinAdaptiveCurrentCount, 1u);
|
||||
if (!AuThreadPrimitives::gSpinAdaptiveThreshold || uNow <= AuThreadPrimitives::gSpinAdaptiveThreshold)
|
||||
@ -203,7 +215,14 @@ namespace Aurora::Threading
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
if (!uEndTimeSteadyNS)
|
||||
{
|
||||
ContextYield();
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user