mirror of
https://github.com/azerothcore/azerothcore-wotlk.git
synced 2026-01-15 23:00:34 +01:00
refactor(Core/Misc): add braces and impove codestyle (#6402)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user