[+] 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 // WARN: these values are not final
bool bNoThreadNames { false }; bool bNoThreadNames { false };
bool bPlatformIsSMPProcessorOptimized { true }; // Whether to attempt to using mm_pause or similar before yielding into the kernel 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 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. // 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. // Adjust this value to compensate for longer critical sections when context switching isn't preferrable.
bool bEnableAggressiveScheduling { false }; AuUInt64 bEnableAggressiveScheduling : 1 { false };
bool bEnableAgrSchedulingRatelimit { true }; AuUInt64 bEnableAgrSchedulingRatelimit : 1 { true };
bool bPreferNt51XpMutexesOver8 { false }; AuUInt64 bPreferNt51XpMutexesOver8 : 1 { false };
bool bPreferNt51XpCondvarsOver8 { false }; AuUInt64 bPreferNt51XpCondvarsOver8 : 1 { false };
bool bPreferNtCondvarModernWinSpin { false }; AuUInt64 bPreferNtCondvarModernWinSpin : 1 { false };
bool bPreferNtCondvarOlderWinSpin { true }; AuUInt64 bPreferNtCondvarOlderWinSpin : 1 { true };
bool bPreferNtSemaphoreSpinTryLock { true }; AuUInt64 bPreferNtSemaphoreSpinTryLock : 1 { true };
bool bPreferNtMutexSpinTryLock { true }; AuUInt64 bPreferNtMutexSpinTryLock : 1 { true };
bool bPreferNtCondMutexSpinTryLock { true }; AuUInt64 bPreferNtCondMutexSpinTryLock : 1 { true };
bool bPreferLinuxSemaphoreSpinTryLock { true }; AuUInt64 bPreferLinuxSemaphoreSpinTryLock : 1 { true };
bool bPreferLinuxMutexSpinTryLock { true }; AuUInt64 bPreferLinuxMutexSpinTryLock : 1 { true };
bool bPreferLinuxCondMutexSpinTryLock { true }; AuUInt64 bPreferLinuxCondMutexSpinTryLock : 1 { true };
bool bPreferEmulatedWakeOnAddress { false }; AuUInt64 bPreferEmulatedWakeOnAddress : 1 { false };
}; };
struct DummyConfig struct DummyConfig

View File

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