mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:08:47 +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 "SendAssetTask.h"
|
||||||
#include "UploadAssetTask.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";
|
const QString ASSET_SERVER_LOGGING_TARGET_NAME = "asset-server";
|
||||||
|
|
||||||
bool interfaceRunning() {
|
bool interfaceRunning() {
|
||||||
|
@ -57,7 +62,7 @@ void updateConsumedCores() {
|
||||||
wasInterfaceRunning = isInterfaceRunning;
|
wasInterfaceRunning = isInterfaceRunning;
|
||||||
auto coreCount = std::thread::hardware_concurrency();
|
auto coreCount = std::thread::hardware_concurrency();
|
||||||
if (isInterfaceRunning) {
|
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;
|
qDebug() << "Setting max consumed cores to " << coreCount;
|
||||||
setMaxCores(coreCount);
|
setMaxCores(coreCount);
|
||||||
|
@ -89,7 +94,7 @@ AssetServer::AssetServer(ReceivedMessage& message) :
|
||||||
connect(qApp, &QCoreApplication::aboutToQuit, [this, timerConnection] {
|
connect(qApp, &QCoreApplication::aboutToQuit, [this, timerConnection] {
|
||||||
disconnect(timerConnection);
|
disconnect(timerConnection);
|
||||||
});
|
});
|
||||||
timer->setInterval(1000);
|
timer->setInterval(INTERFACE_RUNNING_CHECK_FREQUENCY_MS);
|
||||||
timer->setTimerType(Qt::CoarseTimer);
|
timer->setTimerType(Qt::CoarseTimer);
|
||||||
timer->start();
|
timer->start();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1040,7 +1040,7 @@ const std::vector<uint8_t>& getAvailableCores() {
|
||||||
DWORD_PTR defaultProcessAffinity = 0, defaultSystemAffinity = 0;
|
DWORD_PTR defaultProcessAffinity = 0, defaultSystemAffinity = 0;
|
||||||
HANDLE process = GetCurrentProcess();
|
HANDLE process = GetCurrentProcess();
|
||||||
GetProcessAffinityMask(process, &defaultProcessAffinity, &defaultSystemAffinity);
|
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;
|
DWORD_PTR coreMask = 1;
|
||||||
coreMask <<= i;
|
coreMask <<= i;
|
||||||
if (0 != (defaultSystemAffinity & coreMask)) {
|
if (0 != (defaultSystemAffinity & coreMask)) {
|
||||||
|
|
Loading…
Reference in a new issue