refactor(Core/Misc): add braces and impove codestyle (#6402)

This commit is contained in:
Kargatum
2021-06-25 00:50:18 +07:00
committed by GitHub
parent 33c271cc7c
commit 3c24b511f2
72 changed files with 1486 additions and 401 deletions

View File

@@ -31,20 +31,30 @@ void SetProcessPriority(std::string const& logChannel, uint32 affinity, bool hig
ULONG_PTR currentAffinity = affinity & appAff;
if (!currentAffinity)
{
LOG_ERROR(logChannel, "Processors marked in UseProcessors bitmask (hex) %x are not accessible. Accessible processors bitmask (hex): %x", affinity, appAff);
}
else if (SetProcessAffinityMask(hProcess, currentAffinity))
{
LOG_INFO(logChannel, "Using processors (bitmask, hex): %x", currentAffinity);
}
else
{
LOG_ERROR(logChannel, "Can't set used processors (hex): %x", currentAffinity);
}
}
}
if (highPriority)
{
if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
{
LOG_INFO(logChannel, "Process priority class set to HIGH");
}
else
{
LOG_ERROR(logChannel, "Can't set process priority class.");
}
}
#elif defined(__linux__) // Linux
@@ -56,10 +66,14 @@ void SetProcessPriority(std::string const& logChannel, uint32 affinity, bool hig
for (unsigned int i = 0; i < sizeof(affinity) * 8; ++i)
if (affinity & (1 << i))
{
CPU_SET(i, &mask);
}
if (sched_setaffinity(0, sizeof(mask), &mask))
{
LOG_ERROR(logChannel, "Can't set used processors (hex): %x, error: %s", affinity, strerror(errno));
}
else
{
CPU_ZERO(&mask);
@@ -71,9 +85,13 @@ void SetProcessPriority(std::string const& logChannel, uint32 affinity, bool hig
if (highPriority)
{
if (setpriority(PRIO_PROCESS, 0, PROCESS_HIGH_PRIORITY))
{
LOG_ERROR(logChannel, "Can't set process priority class, error: %s", strerror(errno));
}
else
{
LOG_INFO(logChannel, "Process priority class set to %i", getpriority(PRIO_PROCESS, 0));
}
}
#else