Jamie Reece Wilson
b8d4e02ab5
[+] Aurora::Threading::SetThreadingConfig [*] Save a few bytes in Aurora::ThreadingConfig
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
/***
|
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: SMTYield.cpp
|
|
Date: 2023-3-12
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include "SMTYield.hpp"
|
|
|
|
namespace Aurora::Threading
|
|
{
|
|
AUKN_SYM void SetSpinCountTimeout(AuUInt8 uTimeout)
|
|
{
|
|
gRuntimeConfig.threadingConfig.uSpinLoopPowerA = uTimeout;
|
|
}
|
|
|
|
AUKN_SYM AuUInt8 GetSpinCountTimeout()
|
|
{
|
|
return gRuntimeConfig.threadingConfig.uSpinLoopPowerA;
|
|
}
|
|
|
|
AUKN_SYM void SetThreadLocalAdditionalSpinCountTimeout(AuUInt8 uTimeout)
|
|
{
|
|
gHasThreadLocalTimeout = 1;
|
|
tlsSpinCountLocal = uTimeout;
|
|
}
|
|
|
|
AUKN_SYM AuUInt32 GetTotalSpinCountTimeout()
|
|
{
|
|
AuUInt32 uCount {};
|
|
uCount = 1u << AuUInt32(gRuntimeConfig.threadingConfig.uSpinLoopPowerA);
|
|
if (gHasThreadLocalTimeout)
|
|
{
|
|
uCount += 1u << AuUInt32(tlsSpinCountLocal);
|
|
}
|
|
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
|
|
{
|
|
|
|
|
|
} |