2013-10-26 21:19:49 +00:00
|
|
|
#include "System.h"
|
|
|
|
|
|
|
|
#include <QThread>
|
2015-11-18 21:22:09 +00:00
|
|
|
#include <QCoreApplication>
|
2013-10-26 21:19:49 +00:00
|
|
|
|
|
|
|
static int core_count = -1;
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
int System::getCoreCount() {
|
|
|
|
if (core_count < 0) {
|
2013-12-17 22:01:36 +00:00
|
|
|
#ifdef NDEBUG
|
2013-10-26 21:19:49 +00:00
|
|
|
core_count = QThread::idealThreadCount();
|
2015-11-09 21:30:46 +00:00
|
|
|
if (core_count <= 0) {
|
2013-12-17 22:01:36 +00:00
|
|
|
qWarning("Can't find number of CPU cores, using only 1");
|
2013-10-26 21:19:49 +00:00
|
|
|
core_count = 1;
|
|
|
|
}
|
2013-12-17 22:01:36 +00:00
|
|
|
#else
|
|
|
|
core_count = 1;
|
|
|
|
#endif
|
2013-10-26 21:19:49 +00:00
|
|
|
}
|
|
|
|
return core_count;
|
|
|
|
}
|
2015-11-18 21:22:09 +00:00
|
|
|
|
|
|
|
int System::getProcessId() {
|
|
|
|
return QCoreApplication::applicationPid();
|
|
|
|
}
|