mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-15 21:18:06 +02:00
Removing magic numbers
This commit is contained in:
parent
cbc89e77ab
commit
a593a2116a
2 changed files with 8 additions and 3 deletions
|
@ -31,6 +31,11 @@
|
|||
#include "SendAssetTask.h"
|
||||
#include "UploadAssetTask.h"
|
||||
|
||||
static const uint8_t MIN_CORES_FOR_MULTICORE = 4;
|
||||
static const uint8_t CPU_AFFINITY_COUNT_HIGH = 2;
|
||||
static const uint8_t CPU_AFFINITY_COUNT_LOW = 1;
|
||||
static const int INTERFACE_RUNNING_CHECK_FREQUENCY_MS = 1000;
|
||||
|
||||
const QString ASSET_SERVER_LOGGING_TARGET_NAME = "asset-server";
|
||||
|
||||
bool interfaceRunning() {
|
||||
|
@ -57,7 +62,7 @@ void updateConsumedCores() {
|
|||
wasInterfaceRunning = isInterfaceRunning;
|
||||
auto coreCount = std::thread::hardware_concurrency();
|
||||
if (isInterfaceRunning) {
|
||||
coreCount = coreCount > 4 ? 2 : 1;
|
||||
coreCount = coreCount > MIN_CORES_FOR_MULTICORE ? CPU_AFFINITY_COUNT_HIGH : CPU_AFFINITY_COUNT_LOW;
|
||||
}
|
||||
qDebug() << "Setting max consumed cores to " << coreCount;
|
||||
setMaxCores(coreCount);
|
||||
|
@ -89,7 +94,7 @@ AssetServer::AssetServer(ReceivedMessage& message) :
|
|||
connect(qApp, &QCoreApplication::aboutToQuit, [this, timerConnection] {
|
||||
disconnect(timerConnection);
|
||||
});
|
||||
timer->setInterval(1000);
|
||||
timer->setInterval(INTERFACE_RUNNING_CHECK_FREQUENCY_MS);
|
||||
timer->setTimerType(Qt::CoarseTimer);
|
||||
timer->start();
|
||||
#endif
|
||||
|
|
|
@ -1040,7 +1040,7 @@ const std::vector<uint8_t>& getAvailableCores() {
|
|||
DWORD_PTR defaultProcessAffinity = 0, defaultSystemAffinity = 0;
|
||||
HANDLE process = GetCurrentProcess();
|
||||
GetProcessAffinityMask(process, &defaultProcessAffinity, &defaultSystemAffinity);
|
||||
for (uint64_t i = 0; i < sizeof(DWORD_PTR) * 8; ++i) {
|
||||
for (uint64_t i = 0; i < sizeof(DWORD_PTR) * BITS_IN_BYTE; ++i) {
|
||||
DWORD_PTR coreMask = 1;
|
||||
coreMask <<= i;
|
||||
if (0 != (defaultSystemAffinity & coreMask)) {
|
||||
|
|
Loading…
Reference in a new issue