28 lines
515 B
C++
28 lines
515 B
C++
#include "System.h"
|
|
|
|
#include "Logs.h"
|
|
|
|
#include <unistd.h>
|
|
#include <thread>
|
|
|
|
static int core_count = -1;
|
|
|
|
int System::getCoreCount() {
|
|
if (core_count < 0) {
|
|
#ifdef NDEBUG
|
|
core_count = thread::hardware_concurrency();
|
|
if (core_count <= 0) {
|
|
Logs::warning("System") << "Can't find number of CPU cores, using only 1" << endl;
|
|
core_count = 1;
|
|
}
|
|
#else
|
|
core_count = 1;
|
|
#endif
|
|
}
|
|
return core_count;
|
|
}
|
|
|
|
int System::getProcessId() {
|
|
return getpid();
|
|
}
|