[+] Aurora::Threading::GetThreadingConfig

[+] Aurora::Threading::SetThreadingConfig
[*] Save a few bytes in Aurora::ThreadingConfig
This commit is contained in:
Reece Wilson 2023-08-20 16:20:57 +01:00
parent 2a82e406a3
commit b8d4e02ab5
3 changed files with 41 additions and 18 deletions

View File

@ -343,24 +343,24 @@ namespace Aurora
{
// WARN: these values are not final
bool bNoThreadNames { false };
bool bPlatformIsSMPProcessorOptimized { true }; // Whether to attempt to using mm_pause or similar before yielding into the kernel
AuUInt8 uSpinLoopPowerA { 5 }; // Nudgable spinloop power. This is our local userland niceness factor; where 1 << n is the amount of smt-yield instructions to stall for
// This is comparable to Win32's SetCriticalSectionSpinCount applied across every single AuThreadPrimitives try-lock and lock.
// Adjust this value to compensate for longer critical sections when context switching isn't preferrable.
bool bEnableAggressiveScheduling { false };
bool bEnableAgrSchedulingRatelimit { true };
bool bPreferNt51XpMutexesOver8 { false };
bool bPreferNt51XpCondvarsOver8 { false };
bool bPreferNtCondvarModernWinSpin { false };
bool bPreferNtCondvarOlderWinSpin { true };
bool bPreferNtSemaphoreSpinTryLock { true };
bool bPreferNtMutexSpinTryLock { true };
bool bPreferNtCondMutexSpinTryLock { true };
bool bPreferLinuxSemaphoreSpinTryLock { true };
bool bPreferLinuxMutexSpinTryLock { true };
bool bPreferLinuxCondMutexSpinTryLock { true };
bool bPreferEmulatedWakeOnAddress { false };
bool bNoThreadNames { false };
bool bPlatformIsSMPProcessorOptimized { true }; // Whether to attempt to using mm_pause or similar before yielding into the kernel
AuUInt8 uSpinLoopPowerA { 5 }; // Nudgable spinloop power. This is our local userland niceness factor; where 1 << n is the amount of smt-yield instructions to stall for
// This is comparable to Win32's SetCriticalSectionSpinCount applied across every single AuThreadPrimitives try-lock and lock.
// Adjust this value to compensate for longer critical sections when context switching isn't preferrable.
AuUInt64 bEnableAggressiveScheduling : 1 { false };
AuUInt64 bEnableAgrSchedulingRatelimit : 1 { true };
AuUInt64 bPreferNt51XpMutexesOver8 : 1 { false };
AuUInt64 bPreferNt51XpCondvarsOver8 : 1 { false };
AuUInt64 bPreferNtCondvarModernWinSpin : 1 { false };
AuUInt64 bPreferNtCondvarOlderWinSpin : 1 { true };
AuUInt64 bPreferNtSemaphoreSpinTryLock : 1 { true };
AuUInt64 bPreferNtMutexSpinTryLock : 1 { true };
AuUInt64 bPreferNtCondMutexSpinTryLock : 1 { true };
AuUInt64 bPreferLinuxSemaphoreSpinTryLock : 1 { true };
AuUInt64 bPreferLinuxMutexSpinTryLock : 1 { true };
AuUInt64 bPreferLinuxCondMutexSpinTryLock : 1 { true };
AuUInt64 bPreferEmulatedWakeOnAddress : 1 { false };
};
struct DummyConfig

View File

@ -7,6 +7,11 @@
***/
#pragma once
namespace Aurora
{
struct ThreadingConfig;
}
namespace Aurora::Threading
{
// Note: the following APIs are in powers of 2!
@ -15,4 +20,7 @@ namespace Aurora::Threading
AUKN_SYM AuUInt8 GetSpinCountTimeout();
AUKN_SYM void SetThreadLocalAdditionalSpinCountTimeout(AuUInt8 uTimeout);
AUKN_SYM AuUInt32 GetTotalSpinCountTimeout();
AUKN_SYM const ThreadingConfig *GetThreadingConfig();
AUKN_SYM void SetThreadingConfig(const ThreadingConfig *pUpdateConfig);
}

View File

@ -36,6 +36,21 @@ namespace Aurora::Threading
}
return uCount;
}
AUKN_SYM const ThreadingConfig *GetThreadingConfig()
{
return &gRuntimeConfig.threadingConfig;
}
AUKN_SYM void SetThreadingConfig(const ThreadingConfig *pUpdateConfig)
{
if (!pUpdateConfig)
{
return;
}
gRuntimeConfig.threadingConfig = decltype(gRuntimeConfig.threadingConfig)(*pUpdateConfig);
}
}
namespace Aurora::Threading::Primitives